保存在数据库中的日期,我需要从一周前获取数据 [英] date saved in database i need to get the data from week before
问题描述
大家好,
我使用C#和sql server编写程序,将数据保存在数据库中,如下所示:
姓名日期
-------------
约翰2013年1月1日
史蒂芬(Steven)14/2/2013
萨拉2014年3月30日
我需要在打开表单时显示仍到日期一周的名称(只有一个星期到日期的名称)
例子:
当日期为4/2/2913出现为约翰时,当日期为7/2/2013出现史蒂芬等时...
并且我需要在其他形式上显示超出日期的名称,并告诉我它们超过日期多少天
例子:
当日期为15/2/2013时,在datagridview中显示如下:
名称天
------------
约翰4
史蒂文1
请帮助我,我需要做这个程序,我仍然是C#的初学者.
谢谢.
Hi All,
I make a program using C# and sql server i saved data in database like this :
name date
-------------
john 11/2/2013
steven 14/2/2013
sara 30/3/2014
i need when i open the form appear the names which still a week to reach the date (the names there is only one week to reach the date)
example :
when the date be 4/2/2913 appear john,when the date be 7/2/2013 appear steven and etc...
and i need onther form appear the names which exceeded the date and tell me how many days they exceeded the date
example :
when the date be 15/2/2013 appear like this in datagridview:
name days
------------
john 4
steven 1
Please help me i need to do this program necessary and i''m still beginner in C#.
Thanks.
推荐答案
在后端,创建一个返回数据集的过程.
在该过程中,获取databasecolumn_date和systemdate的日期差异.
检查差异并相应返回结果.
查看此链接以进行使用.
http://www.w3schools.com/sql/func_datediff.asp [
Hi,
At the back end,create a procedure which returns the dataset.
In the procedure get the datedifference of databasecolumn_date and systemdate.
Check the difference and return the result accordingly.
Check out this link for usuage.
http://www.w3schools.com/sql/func_datediff.asp[^]
Hope this helps.
使用 DateDiff [ ^ ]使用SQL或 ^ ] in c#
use DateDiff[^] in SQL or TimeSpan[^] in c#
这篇关于保存在数据库中的日期,我需要从一周前获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!