Arod1207
Arod12078mo ago

How can i work with dates?

I have a date picker and sending the date as a string to the backend, I want to be able to query by month. I may be doing this completely wrong, so any advice would be appreciated. Thank you
4 Replies
Abhishek
Abhishek8mo ago
So in convex backend , add use node on the top and do use like this new Date(time from your database as string).toUTCString()
Arod1207
Arod1207OP8mo ago
Thanks!
sshader
sshader8mo ago
Just to link to the existing docs in this area: https://docs.convex.dev/database/types#working-with-dates-and-times Your main options are to store the date as a number (ms since epoch) or as a string in a standard format -- there are several js libraries for dealing with Date strings (usually backed by Date.parse which works in both the Convex runtime and node)
Data Types | Convex Developer Hub
All Convex documents are defined as Javascript objects. These objects can have
Michal Srb
Michal Srb8mo ago
"want to be able to query by month" Dates are hard (as the docs Sarah linked to allude to). This description is ambiguous. Depending on what you need, you can either: - query from some start timestamp (beginning of a month in some timezone) to some end timestamp - store the actual date string in YYYY/MM/DD format then query lexicographically

Did you find this page helpful?