PDA

View Full Version : Solved: retrive date in sql or vb.6



shamsam1
11-08-2008, 02:44 AM
i have date filed stored as nvarchar in sql server=
joindate=20/10/2008
relivingdate=
i want to retive reliving date from joining date
employee joining date is as below20th of October 2008
ex
if joining date is 20/10/2008 reliving date should be 19/10/2009 i.e one day before one year
i want sql qurey to retrive the reliving date...
or vb code..

Demosthine
11-08-2008, 09:22 PM
Evening Sham.

In either, you can use:
DateAdd Functions
- Or -
Month, Day, Year Functions

Enjoy.
Scott

shamsam1
11-08-2008, 11:38 PM
hi scott
ya i used dayadd fynction



SELECT DATEADD(Year, 1, 20-10-2007) AS NewDate i am able to increase the year but

one day before ..how to do that.. ..

it should display 19-10-2008

Demosthine
11-09-2008, 11:39 AM
Good Morning.

You can either nest the DateAdd to add a year and subtract a day
DateAdd("yyyy", 1, Date("d", -1, [JoinDate])) AS [NewDate]

- OR -

Take the number of days in a normal year and subtract 1.
DateAdd("d", 364, [JoinDate]) AS [NewDate]

Take care.
Scott

shamsam1
11-09-2008, 09:23 PM
perfect,,,,

thanks scott...