SELECT USR_LOGINNAME,USR_EMAIL FROM USERS
WHERE STATUS= 1 AND
TIMESTAMPDIFF(DAY,MODIFIED_DATE,CURRENT_TIMESTAMP)=1;
使用datediff(enddate, startdate)
函数:
datediff(current_date, date(MODIFIED_DATE)) = 1
如果enddate小于startdate,结果为负
如果你想要昨天的数据,我建议:
WHERE STATUS = 1 AND
MODIFIED_DATE < CURRENT_DATE AND
MODIFIED_DATE >= DATE_ADD(CURRENT_DATE, -1)
这允许Hive使用MODIFIED_DATE
进行优化,例如分区修剪。