Pentium10
Pentium10

Reputation: 207952

How to get how many days are in the current year?

How do I get how many days are in the current year (365,366) using Sqlite?

select contact_id as _id,data1,display_name, (strftime('%j',data1)-strftime('%j','now')+365) % 365 as indays from contact_birthday where indays >-200 order by indays asc, display_name asc LIMIT 25

I would like to replace 365 with the valid days for a leap year.

Upvotes: 1

Views: 247

Answers (2)

rcmuthu786
rcmuthu786

Reputation: 130

You can use below query for how many days in a year:- select add_months(trunc(sysdate,'year'), 12) - trunc(sysdate,'year') from dual

Upvotes: 0

Kenny Peng
Kenny Peng

Reputation: 1931

You could compute the difference in days between the start of this year and the start of next year, like so (a bit dirty, though):

sqlite> SELECT julianday('now', 'start of year', '+1 year') - julianday('now', 'start of year');
365

Upvotes: 3

Related Questions