SQLite: How to calculate age from birth date

后端 未结 8 1849
独厮守ぢ
独厮守ぢ 2020-12-16 15:00

What is the best way to calculate the age in years from a birth date in sqlite3?

8条回答
  •  鱼传尺愫
    2020-12-16 15:35

    You can convert the dates to floating point numbers and subtract…

    cast(strftime('%Y.%m%d', 'now') - strftime('%Y.%m%d', dob) as int)
    

    …where dob is a valid SQLite time string.

提交回复
热议问题