开发者

How do I pass parameter as Date in vb.net web?

I have a mail webform where I have to show the user only (-1) one day behind messages, so how do pass (yesterday)date as parameter and retrieve the only records of one day back开发者_如何学C ? This query is for 'ALL' messages, but I need to filter (yesterday) one day back messages and add a hyperlink or add in a dropdown ?

select MSG_SRNO,MSG_SUBJECT,MSG_ID,MSG_CHKD,
   DOF_SENT,DOF_SEEN from  MESSAGES_MAILBOX where  USER=1234


In sql, try

SELECT DATEADD(day,-1, GETDATE());


This should work:

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜