SQL PHP - 如何通过时间戳获取特定日期的记录 [英] SQL PHP - How to get records of specific day by timestamp
问题描述
我有一个 SQL 数据库,其中有一列A",其中包含时间戳.
如何返回时间戳不属于当前日期的所有值.所以说例如它的星期一,我想返回不是这个星期一的所有值.
使用 DATE() 或 CURDATE() MySQL 函数:-
返回所有当前日期的值:-
select * from table where DATE(emailsend)=CURDATE()
返回所有不是当前日期的值:-
select * from table where DATE(emailsend) !=CURDATE()
<块引用>
或者使用 MySQL WEEKDAY() 返回一周中某一天的索引给定日期(0 表示周一,1 表示周二,......6 表示周日)
select * from table where WEEKDAY(emailsend) !=0//返回所有非星期一的值
I have a SQL database that has a column "A" that has timestamps in it.
How do I return all values that have a timestamp that doesnt fall under the current day. So say for example its Monday, i want to return all values that are not this Monday.
Use DATE() or CURDATE() MySQL function:-
Return all values that are current date :-
select * from table where DATE(emailsend)=CURDATE()
Return all values that are not current date :-
select * from table where DATE(emailsend) !=CURDATE()
Or use MySQL WEEKDAY() returns the index of the day in a week for a given date (0 for Monday, 1 for Tuesday and ......6 for Sunday)
select * from table where WEEKDAY(emailsend) !=0
//Return all values where day not is monday
这篇关于SQL PHP - 如何通过时间戳获取特定日期的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!