我有一个邮件webform,我必须在消息后一天只显示用户(-1),那么如何将(昨天)日期作为参数传递并检索一天的唯一记录? 此查询用于“所有”消息,但我需要过滤(昨天)一天回邮件并添加超链接或添加下拉列表?
select MSG_SRNO,MSG_SUBJECT,MSG_ID,MSG_CHKD,
DOF_SENT,DOF_SEEN from MESSAGES_MAILBOX where USER=1234
答案 0 :(得分:1)
在sql中,尝试
SELECT DATEADD(day,-1, GETDATE());
答案 1 :(得分:-1)
这应该有效:
DateTime yesterday = DateTime.Now.AddDays(-1);
string query = string.Format("select MSG_SRNO,MSG_SUBJECT,MSG_ID,MSG_CHKD,DOF_SENT,DOF_SEEN from MESSAGES_MAILBOX where DATEPART(year,DOF_SENT) = {0} AND DATEPART(month,DOF_SENT) = {1} AND DATEPART(day,DOF_SENT) = {2}",yesterday.Year,yesterday.Month, yesterday.Day);