Comparing dates

Assume we have a date like 2014-09-05 09:23:35.000 and we want to compare that to 5 May 2014 09:23:35 the simplest way is to convert the date into a number.

In sql server we can do this using the following code when dealing with sql dates

select GetDate(), DATEDIFF(s, '1970-01-01 00:00:00', GetDate())

In sql server we can do this using the following code when dealing with dates strings

select GetDate(), DATEDIFF(s, '1970-01-01 00:00:00', convert(datetime, '5 May 2014 09:23:35'))

In javascript this is

Math.round(new Date().getTime()/1000.0)

In VbScript this is

DateDiff("s", "01/01/1970 00:00:00", Now())

Its then fairly simple to compare the numeric values irrespective of date formats