TriggerMe
SSChampion
Points: 11752
More actions
June 17, 2010 at 4:51 pm
#222386
I have this query which almost does what I need it to do.
It returns a date of 2010-03-18 08:46:54.027
How do you get it to return 2010-03-01
The time portion doesn't matter it can be 00:00:00
SELECT DATEADD(m, -3, GETDATE())
David Webb-CDS
SSCoach
Points: 17398
June 17, 2010 at 5:16 pm
#1181879
I'm not clear what you want it to do, but the following link has a lot of good utility date calculations and can probably lead you to what you need.
http://qa.sqlservercentral.com/blogs/lynnpettis/archive/2009/3/25/some-common-date-routines.aspx
June 17, 2010 at 5:28 pm
#1181882
Hi,
From that link I was able to work out what I needed to do.
This is what I needed, I needed to get the first day of the month of the current year 3 months ago from today.
DATEADD(Month, DATEDIFF(MONTH, 0, GETDATE()) -3, 0)
Returns,
2010-03-01 00:00:00.000
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply