How to store and get datetime value in SQLite

前端 未结 3 1518
感情败类
感情败类 2020-12-28 21:27

My table contains Birthdate field which has datatype as datetime. I want to get all records having birthday today. How can I get it?

3条回答
  •  礼貌的吻别
    2020-12-28 22:13

    Having a special datetime type has always seemed like unnecessary overhead to me, integers are fast, flexible, and use less space.

    For general datetime values use Unix Epoch timestamps. Easy to work with, extremely flexible, as well as timezone (and even calender!) agnostic. (I recently wrote an article on using them, which I really have to plug...)

    That said, if you're only interested in dates in the Gregorian calendar you may want to use a large integer in the following format: YYYYMMDD, eg 19761203. For you particular usage you could even create a four digit integer like MMDD, say 1703 — that's got to result in fast selects!

提交回复
热议问题