Fork me on GitHub
#sql
<
2018-04-19
>
shaun-mahood16:04:11

Should there be any translation of dates or times going on when querying using clojure.java.jdbc? I'm querying MS SQL Server, if I run the query outside of my Clojure program it returns 2018-04-16 21:44:36.000, but from my program I'm getting #inst"2018-04-17T03:44:36.000000000-00:00" I've got clj-time required in other parts of my program but not directly in that file, and I've also got honeysql required in my namespace but I'm not using it for this query. I'm assuming that there's something in my dependencies that is doing something weird, but since dates and times are so much fun I figured I would see if anyone has run into something like this in case I'm not thinking of something else.

hiredman16:04:30

if I recall, many jdbc drivers will assume dates in the database are in utc and try to translate them to the local timezone

hiredman16:04:02

so I would check what timezone the jvm thinks it is running in

hiredman16:04:39

(if the column type doesn't store a timezone)

shaun-mahood16:04:44

@hiredman Thanks! I wouldn't have thought of looking at the JVM at all. I stored everything UTC but I want to get it back out as UTC too, so that is likely where things are going awry.

seancorfield17:04:53

@shaun-mahood Best practice is to have all your servers (both database and application) set to UTC, and make sure the database is configured to UTC as well.

seancorfield17:04:03

Timezones are just hell.

👍 8
shaun-mahood17:04:50

The crappy thing is that I really do only need local time, but I have been using UTC because local time was such a pain in the butt last time I started a new project. Oh well.