How do I compare sqlite timestamp with C# DateTime? I have:
string query = string.Format(@"select avg(CPUH_VALUE_ALL) as Value from CPU_HOUR where CPUH_DATE >= @Date");
var pars = new List<SQLiteParameter>();
pars.Add(new SQLiteParameter("Date", DateTimeSQLite(DateTime.Now.AddMinutes(-12))));
where
static string DateTimeSQLite(DateTime datetime)
{
string dateTimeFormat = "{0}-{1}-{2} {3}:{4}:{5}.{6}";
return string.Format(dateTimeFormat, datetime.Year, datetime.Month, datetime.Day, datetime.Hour, datetime.Minute, datetime.Second, datetime.Millisecond);
}
That wouldn't work. And nothing works when I try compare timestamp with string value of date in various formats either. Any clues?
Edit
select CPUH_DATE from CPU_HOUR where CPUH_DATE
get me records like this:
5/19/2014 9:30:54 PM
Edit2 I've just discovered that while this is not working:
select * from CPU_HOUR where CPUH_DATE >= '2014-5-19 21:30:08'
this is (note the zero before 5):
select * from CPU_HOUR where CPUH_DATE >= '2014-05-19 21:30:08'
Interesting.