Using sql.lit
Hey
I have a question about using sql.lit and using dates
I get the date as string, is there a way to get the date as date ?
is there a better way of doing it ?
6 Replies
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
how do I use sql.lit with date ? is it possible ? because when I used it in the example above I got string instead of date
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
sql.lit
means "interpolate this value to the SQL string as-is and don't use parameters". A Date gets turned into an ISO string and the db engine has no idea the string represents a Date. You need to cast it to tell the db the type.Ok thank you
So something like
if you're using postgres. The correct type is probably
datetime
on MySQL.
Postgres also has a nicer cast syntax: