Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何在where子句中对unixtimestamp(bigint)列使用curdate()_Mysql_Unix Timestamp - Fatal编程技术网

Mysql 如何在where子句中对unixtimestamp(bigint)列使用curdate()

Mysql 如何在where子句中对unixtimestamp(bigint)列使用curdate(),mysql,unix-timestamp,Mysql,Unix Timestamp,我试图在过去的7天内提取记录。这是我一直试图开始工作的select语句: select from_unixtime(time,'%m/%d/%y') as fdate, from_unixtime(time,'%h:%m:%s') as ftime from mdl_log where from_unixtime(time,'%y-%m-%d') between curdate() and curdate() - INTERVAL 7 DAY 我已经尝试过where子句的各种形式,比如 wh

我试图在过去的7天内提取记录。这是我一直试图开始工作的select语句:

select from_unixtime(time,'%m/%d/%y') as fdate, from_unixtime(time,'%h:%m:%s') as ftime
from mdl_log
where from_unixtime(time,'%y-%m-%d')  between curdate() and curdate() - INTERVAL 7 DAY
我已经尝试过where子句的各种形式,比如

where time between curdate() and curdate() - INTERVAL 7 DAY


选择curdate()-结果以这种格式显示日期2012-11-08

您的上一次化身就在那里。然而,你需要对苹果进行比较。由于
时间
是一个整数,因此需要将其转换以供使用

考虑到您的用例,您实际上只需要:


嗯,谢谢你的回复。我使用about建议中的任意一个得到一个空结果集。我也尝试过添加FROM_UNIXTIME(时间,%yyyy-%mm-%dd')。最后我使用了这个语句,其中DATE(FROM_UNIXTIME(时间,%Y-%m-%d'))>DATE(CURDATE()-INTERVAL 7 DAY)是不必要的。我想你还是没抓住重点。考虑到
time
是一个
BIGINT
,我提供的两个示例都应该有效。
where from_unixtime(time,'%yyyy-%mm-%dd')  between curdate() and curdate() - INTERVAL 7 DAY
where date(time) between curdate() and curdate() - INTERVAL 7 DAY
WHERE DATE(FROM_UNIXTIME(time)) between CURDATE() and CURDATE() - INTERVAL 7 DAY
WHERE FROM_UNIXTIME(time) between CURDATE() and CURDATE() - INTERVAL 7 DAY