I'm editing a query i build in ms sql.
I need to order the items on date, but that gives an error.
locations_aanvang
gives 2012-08-12
(yyyy-mm-dd). so i extend it to 2012-08-12 00:00:00 +1:00
for EST time.
So to order the i need to convert it to unix timestamp (right?).
The query is:
SELECT TOP 6 * FROM jd_lighthouses
WHERE locations_aanvang != ''
ORDER BY (SELECT DATEDIFF(s, '1970-01-01', locations_aanvang+' 00:00:00 +1:00')) DESC
And the error i get is:
[Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.
What am i doing wrong? and can i do this easier?
Thanks in advance!
Kind regards, Bram Hammer