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:Jump to 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....4 Replies
Hello, @Matt! You don't need extra quetes in default statement
Do you want to filter on application level or in db?
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
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.No worries, that's what I ended up doing in the end. I look forward to the date mode. Thanks.