How do I filter with date in SQLite (Turso)

I can't find an answer in the docs but I have a timestamp defined in my schema like this updatedAt: text('updated_at').default(sql``(CURRENT_TIMESTAMP)``).notNull(), I'm trying to see whether this timestamp was in the last 24 hours but because the type is seen as a string it won't let me check it with Date and lt etc. What am I missing? Thanks.
Solution:
Sorry for long response @Matt. You might convert this field into date in your application and do your filters. Also, there will be soon date mode for the text data type in sqlite, so this field will be already returned as Date object from drizzle....
Jump to solution
4 Replies
Mykhailo
Mykhailo8mo ago
Hello, @Matt! You don't need extra quetes in default statement
default(sql`(CURRENT_TIMESTAMP)`)
default(sql`(CURRENT_TIMESTAMP)`)
Do you want to filter on application level or in db?
Matt
MattOP8mo ago
Thanks @Mykhailo . Sorry, I think that was just me trying to escape the backticks. I've been trying at a application level with no luck so far.
Solution
Mykhailo
Mykhailo8mo ago
Sorry for long response @Matt. You might convert this field into date in your application and do your filters. Also, there will be soon date mode for the text data type in sqlite, so this field will be already returned as Date object from drizzle.
Matt
MattOP8mo ago
No worries, that's what I ended up doing in the end. I look forward to the date mode. Thanks.
Want results from more Discord servers?
Add your server