简体   繁体   中英

Sqlite datetime greater than for a particular month

I am trying to select data based on if a month-year is greater than another month-year in SQLITE using the following query:

SELECT id, start_date, end_date FROM recur WHERE strftime('%m%Y', start_date) <= '122012' AND strftime('%m%Y', end_date) >= '122012'

I have a row in the database with:
  start_date = 2012-12-01
  end_date = 2015-05-01

The problem seems to be with the greater than function, and after changing the data around does not seem to be able to carry out the greater than. Can anyone help?

您必须将年份放在第一位,以便在字符串比较中获得更大的权重:

strftime('%Y%m')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM