Skip to content

How to add current timestamp in SQL? #3049

Closed Answered by simolus3
JosephKorel asked this question in Q&A
Discussion options

You must be logged in to vote

sqlite only supports a few column types and has special rules on how type names are mapped to them, which drift is following too. There is no builtin date time in sqlite3, you'd instead use TEXT for that.

Inside of drift files, you can use the special DATETIME type name to indicate that the column stores date time values as described here. Drift will then create the column as TEXT or INTEGER depending on how you want drift to store date times. I suggest enabling the store_date_time_values_as_text builder option as described in that link, then you can use CURRENT_TIMESTAMP as a default value.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by JosephKorel
Comment options

You must be logged in to vote
4 replies
@simolus3
Comment options

@JosephKorel
Comment options

@simolus3
Comment options

@JosephKorel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants