tags:

views:

44

answers:

1

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.

+2  A: 

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
Kenny Peng