|
Home > Archive > Microsoft SQL Server forum > February 2006 > Last Year Month to Date Function
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Last Year Month to Date Function
|
|
| Frank Bishop 2006-02-16, 3:24 am |
| I have been spoiled by some report writing tools that have intrinsic
functions like Last Year Month-to-date. I'm looking for a way to emulate
this in SQL Server now with my fields that are date/time.
I'm thinking I need to develop a user defined function to accept a date
input parameter, but I don't know where to start.
Help/Examples appreciated.
Thanks,
Frank
*** Sent via Developersdex http://www.droptable.com ***
| |
| Razvan Socol 2006-02-16, 3:24 am |
| Hi, Frank
If you have a date and you want to obtain the corresponding date in the
previous year, you can use the DATEADD function, like this:
DATEADD(year, -1, @TheDate). For more informations, see:
http://msdn.microsoft.com/library/e..._fa-fz_2c1f.asp
Razvan
|
|
|
|
|