September 1, 2004 at 1:30 am
I need to fetch the monthname in full
like january, march.
I need to pass only the month(numeric).
Ex.
DateName(month,GetDate())
fetches the month as September.
Likewise
I need to get the month
given only the month number.
Like
datename(month,monthnumber)
Thanx in Advance
September 1, 2004 at 6:02 am
u create it user defined function for this req.In my knowledge no other function like ur req.
September 1, 2004 at 6:54 am
DECLARE @monthnumber int
SET @monthnumber = 9
SELECT DATENAME(month,DATEADD(month,@monthnumber - 1,0))
Far away is close at hand in the images of elsewhere.
Anon.
September 3, 2004 at 6:16 am
The most effective way is to have a date dimension table with all the math and breakouts on a date already done. Or, if you do not need that level of control, simply create a table to hold the months like this:
Month_Nbr
Month_Name
Month_Abbrev
Now you will not have to use a function that is called for every line that is returned, you simply do a SQL join.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply