比较字符串日期和没有日期的日期
Compare dates which are strings and which have no day
我想比较字符串日期和没有日期的日期。
我的 table 看起来像这样:
+-------------+------------------+
| mois(str) | nbr(int) |
+-------------+------------------+
| 2020-01 | 4132 |
| 2020-02 | 7851 |
| 2020-03 | 8351 |
| 2020-04 | 1564 |
| 2020-05 | 1452 |
| 2020-06 | 6421 |
+-------------+------------------+
例如,我想根据 'mois'
列获取“2020-02”和“2020-04”之间的每一行
+-------------+------------------+
| mois(str) | nbr(int) |
+-------------+------------------+
| 2020-02 | 7851 |
| 2020-03 | 8351 |
| 2020-04 | 1564 |
+-------------+------------------+
你能帮帮我吗?谢谢!
YYYY-MM
格式可以直接过滤,所以你可以这样做:
where mois >= '2020-02' and mois <= '2020-04'
或使用between
:
where mois between '2020-02' and '2020-04'
我想比较字符串日期和没有日期的日期。 我的 table 看起来像这样:
+-------------+------------------+
| mois(str) | nbr(int) |
+-------------+------------------+
| 2020-01 | 4132 |
| 2020-02 | 7851 |
| 2020-03 | 8351 |
| 2020-04 | 1564 |
| 2020-05 | 1452 |
| 2020-06 | 6421 |
+-------------+------------------+
例如,我想根据 'mois'
列获取“2020-02”和“2020-04”之间的每一行+-------------+------------------+
| mois(str) | nbr(int) |
+-------------+------------------+
| 2020-02 | 7851 |
| 2020-03 | 8351 |
| 2020-04 | 1564 |
+-------------+------------------+
你能帮帮我吗?谢谢!
YYYY-MM
格式可以直接过滤,所以你可以这样做:
where mois >= '2020-02' and mois <= '2020-04'
或使用between
:
where mois between '2020-02' and '2020-04'