本文介绍了小于15天的日期列的gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图,其中有一列显示记录的发布日期
我希望网格视图显示过去15天内发布的数据
如何编写我的select命令,以便选择仅比当前日期和时间短15天的记录.

我正在将ASP.NET与C#一起使用

我在SqlSelectCommand中尝试了类似"WHERE DatePosted< = DateTime.UtcNow"的内容
并且还尝试了"WHERE DatePosted< = @datePosted"并添加了command.parameteres.AddwithValue("@ DatePosted",DateTime.UtcNow),但显然我缺少了一些重要的代码,因为它不起作用

我是ASP.NET的新手,迫切需要帮助来处理日期列
任何对新人有用的帮助都将受到高度赞赏

请帮助
最好的问候

I have a grid view with a column showing date on which record was posted
I want the grid view to show data which is posted within last 15 days
How do I write my select command so that the only records less than 15 days old compared to current date and time are selected.

I am using ASP.NET with C#

I have tried something like "WHERE DatePosted <= DateTime.UtcNow" in the SqlSelectCommand
and also tried "WHERE DatePosted <= @datePosted" and added command.parameteres.AddwithValue("@DatePosted", DateTime.UtcNow) but apparently I am missing some important code, as it does not work

I am new to ASP.NET and desperately need help to deal with date column
Any kind of help that can be useful for a new person shall be highly appreciated

Kindly help
Best Regards

推荐答案



这篇关于小于15天的日期列的gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 16:08