sql

grav 2023-08-27T06:58:33.807759Z

Howdy! I've been strugling with translating this:

SELECT datetime(message.date / 1000000000 + strftime('%s','2001-01-01'),'unixepoch','localtime') AS d
into HoneySQL. I wonder if the https://cljdoc.org/d/com.github.seancorfield/honeysql/2.4.1045/doc/getting-started/sql-special-syntax-#raw directive is my only option?

grav 2023-08-27T07:02:42.694579Z

{:select [:%datetime.message/chat]}
is as far as I can get

Raghav 2023-08-27T07:14:00.896839Z

it's fairly simple actually.

{:select [[[:datetime [:+ [:/ :message.date 10] [:strftime :x "2001-01-01"]] "unixepoch", "localtime"] :d]]}

grav 2023-08-27T07:18:39.012319Z

Oh, so I just need to convert it to prefix-notation. Pretty clever. Not sure why I didn't get that from the docs. Maybe I just needed more examples. Thanks @raghavsharma

Raghav 2023-08-27T08:46:56.347669Z

Yes. Just how you would do it in Clojure code. I've very rarely used the raw directive.

👍 1
seancorfield 2023-08-27T15:54:53.727459Z

For the future, the #honeysql channel exists for library-specific questions. This channel #sql is intended for SQL itself, databases, and next.jdbc.

👍 1