如何检查特定日期在日期间?日期

2023-09-13 02:17:52 作者:我本冷情怎暖你心

我在该数据库有两个柱的开始和结束。开始和结束都是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)