S
Synthologic
Guest
I have the following string for the Database: 2014-09-11 11:50:00.0000000
I want to check if the record was created in the last hour. (I would rather not do this in the DB).
So I created this method:
public static bool InLastHour()
{
string dbDateTime = "2014-09-11 11:50:00.0000000";
//The date time is actually a variable.
DateTime arrival = Convert.ToDateTime(dbDateTime);
DateTime now = DateTime.Now;
DateTime yesterday = now.AddDays(-23);
return (arrival > yesterday && arrival <= now);
}
//Another version here:
public static bool InLastHour()
{
string dbDateTime = "2014-09-11 01:51:46.2300000";
DateTime arrival = new DateTime();
arrival = Convert.ToDateTime(dbDateTime);
return (arrival <= DateTime.Now.AddHours(-23));
}
I am getting mixed results.
Thanks
Continue reading...
I want to check if the record was created in the last hour. (I would rather not do this in the DB).
So I created this method:
public static bool InLastHour()
{
string dbDateTime = "2014-09-11 11:50:00.0000000";
//The date time is actually a variable.
DateTime arrival = Convert.ToDateTime(dbDateTime);
DateTime now = DateTime.Now;
DateTime yesterday = now.AddDays(-23);
return (arrival > yesterday && arrival <= now);
}
//Another version here:
public static bool InLastHour()
{
string dbDateTime = "2014-09-11 01:51:46.2300000";
DateTime arrival = new DateTime();
arrival = Convert.ToDateTime(dbDateTime);
return (arrival <= DateTime.Now.AddHours(-23));
}
I am getting mixed results.
Thanks
Continue reading...