SQL has a DateName function, however it takes a datetime as a parameter, not a number
Usage is as follows
DATENAME(month,date) returns Month Name
Sample Query
SELECT DATENAME(month, GETDATE()) AS ‘Month Name’
——————————
Output: January
Suppose i want to print previous month date, how can i do. There is a quick way.
print(DATENAME(month,DATEADD (month , -1, getdate() )))
The dateadd DATEADD (month , -1, getdate() ) function deducts one month from current date, then i will use DateName() function to print the previous month date.
Current Month: January, so
Output: December
so that’s all for now.. it’s simple for you, just i thought of posting may be useful for somebody..
Enjoy coding..