Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

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.
 
Share this answer
 
v2
Comments
tranesyasd 15-Feb-12 11:33am    
i do this :
SELECT DATEDIFF(day,DATETIME.now,[enddate])
FROM person;

but datetime.now not recognized .
manognya kota 15-Feb-12 11:40am    
use Getdate()
tranesyasd 15-Feb-12 11:48am    
i used this :
da.SelectCommand = new SqlCommand("SELECT DATEDIFF(day,GETDATE(),enddate) AS dateend FROM Person", cn);

and its worked and give me the dates right.
thank you very much manognya kota.
manognya kota 15-Feb-12 12:36pm    
Welcome always :) Happy coding.
use DateDiff[^] in SQL or TimeSpan[^] in c#
 
Share this answer
 
Comments
tranesyasd 15-Feb-12 11:09am    
thank you for your cooperation.
Please can you tell me how can i use this? can you give me example ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900