SQL format date and change time zone

Question one: I’m trying to extract data from an SQL. But the problem is that the date column is in milliseconds since 1970.
If I change the format in SQL management studio via Convert(date… the result is correct. But when I paste the same query into Squaredup the convert function does not work. Any ideas?

Question two: From the result above I managed to convert it to correct date. But now the problem is that the time zone is wrong. I get GMT now and need CET Any idea how to convert it from an squaredup query? The way to do it via sql management studio does not work when running it in squaredup.

The query looks like this now:

SELECT title, DESCRIPTION, convert(varchar(64),dateadd(SS, SCHEDULEDSTARTTIME/1000, '1970-1-1')) AS SCHEDULEDSTARTTIME, convert(varchar(64),dateadd(SS, SCHEDULEDENDTIME/1000, '1970-1-1')) AS SCHEDULEDENDTIME
FROM ChangeDetails
WHERE ((ChangeDetails.SCHEDULEDSTARTTIME/1000 > (((datediff (s, '1970-01-01', getdate()))-604800))) AND (ChangeDetails.SCHEDULEDENDTIME/1000 < (((datediff (s, '1970-01-01', getdate()))+604800))))

I found the answer to question one

I had used convert(date…)

and squaredup want convert(varchar(64…

Always read the documentation first ?


No wonder you’re doing so well on the Leaderboard, correctly answering your own questions :wink:

You got me :wink: But I did run it another problem now so now you have the chance to give the right answer first :slight_smile: