Skip to content

How to migrate column type from Text to DateTime with a custom cast expression #1421

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

You must be logged in to vote

I already posted this in Gitter, but this has a better visibility :)

In sqlite3, you can convert a date time (stored as text) into UNIX seconds with strftime('%s', datetime(your date time)). The corresponding action in moor is FunctionCallExpression<DateTime>('strftime', [Constant('%s', FunctionCallExpression('datetime', table.yourDateColumn))]), which you can use in a column transformer.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CalvinGonsalves
Comment options

Answer selected by simolus3
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