mssqlw
mssqlw

Reputation: 73

Sql lite - date calculation result is in year only

I have col1 with date inserted values... YYYY-MM-DD

I am trying to do simple date calculation with returning days

select current_date - col1 from my_table;

This result calculates only years, but i am trying to get only days since two dates. Any suggestions?

Upvotes: 0

Views: 43

Answers (1)

ravenspoint
ravenspoint

Reputation: 20496

Compute the number of days since the signing of the US Declaration of Independence.

SELECT julianday('now') - julianday('1776-07-04');

from https://www.sqlite.org/lang_datefunc.html

So you should be able to write something like this

select julianday('now') - julianday( col1 ) from my_table;

Upvotes: 2

Related Questions