如何检查特定日期在日期间? [英] How to check that certain date in between of date?

查看:98
本文介绍了如何检查特定日期在日期间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在该数据库有两个柱的开始和结束。开始和结束都是DD.MM.YYYY格式。

I have a database in that there are two column start and end. start and end are in DD.MM.YYYY format.

我这也是DD.MM.YYYY格式的日期。 如何检查我的日期是起点和终点之间。

I have a date which is also in DD.MM.YYYY format. How can I check that my date is between start and end.

请推荐一些查询检查这些条件和其他列获取数据。

Please suggest some query for checking these condition and fetching data from other column.

推荐答案

由于乔恩斯基特写,你应该存储在日期 YYYY-MM-DD 格式。

As Jon Skeet wrote, you should have stored the dates in yyyy-mm-dd format.

然而,有可能通过重新排序字段以将您的日期值到正确的日期值上飞(如果字符串中的字段具有固定的长度):

However, it might be possible to convert your date values into proper date values on the fly by reordering the fields (if the fields in the string have a fixed length):

SELECT *
FROM MyTable
WHERE '2013-03-11' BETWEEN substr(StartDate, 7, 4) || '-' ||
                           substr(StartDate, 4, 2) || '-' ||
                           substr(StartDate, 1, 2)
                       AND substr(EndDate, 7, 4) || '-' ||
                           substr(EndDate, 4, 2) || '-' ||
                           substr(EndDate, 1, 2)

这篇关于如何检查特定日期在日期间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆