hello all, i m working with some application where i want to post an email on calculated date which is from some table in database.
i just want to calculate the days between two dates one is getdate() and second is getdate()-14 days..
plz guide me on this..
If second date is getdate()-14 days, then you must already know that there is 14 days diff?
Or are you trying to calculate the starting date? If that's the case, you need to use the DATEADD function in T-SQL:0 johram 7/9/2008 10:22:54 AM
johram:If second date is getdate()-14 days, then you must already know that there is 14 days diff?
johram replied already you know the actual differance between two dates then .. what days needs to be calualted?
might be you are trying to calucalte the date difference between two dates.
SELECT DateDiff( DD,DATEADD(day,-14,GetDATE()),'2008-07-05')
Please remember to click "Mark as Answer" on this post if it helped you.
SELECT [yourcolumn list] FROM yourTable
WHERE dtColumn>DateAdd(second, -1, DateAdd(day, DateDiff(day, 0, getdate()), 0))
AND dtColumn<=DateAdd(second, -1, DateAdd(day, DateDiff(day, 0,getdate()), 14)) --Change this number for days.