SQL 中的 strtotime 是什么?
What is equivalent of strtotime in SQL?
我在第一个 table 中有一个日期,格式 2016-12-20
我需要将它与第二个 table 中的另一个日期进行比较,格式为
2016-12-21 18:40:22
在 php 我可以用
改变这种格式
$date = date("Y-m-d", strtotime($date));
SQL 中 strtotime 的等价物或我如何比较 [=32 中不同格式的 2 个日期=]?
我阅读了 this question 并尝试了这个
select STR_TO_DATE(date, '%y-%m-%d') from second_table;
但是它 returns NULL
您可能需要使用 date_format()
我在第一个 table 中有一个日期,格式 2016-12-20
我需要将它与第二个 table 中的另一个日期进行比较,格式为
2016-12-21 18:40:22
在 php 我可以用
改变这种格式$date = date("Y-m-d", strtotime($date));
SQL 中 strtotime 的等价物或我如何比较 [=32 中不同格式的 2 个日期=]?
我阅读了 this question 并尝试了这个
select STR_TO_DATE(date, '%y-%m-%d') from second_table;
但是它 returns NULL
您可能需要使用 date_format()