declare @.CurrentDate datetime
set @.CurrentDate = GetDate()
select DATENAME(m, @.CurrentDate) + ' ' + DATENAME(yy, @.CurrentDate)
|||Im using visual basic business intelligence. I did figure out the year...
=Year(Parameters!reportdate.Value)
I want the month to be displayed as November, January, July...etc not 11, 1, 7 '
=Month(Parameters!reportdate.Value) gives me 10 which I dont want
and
=MonthName(Parameters!reportdate.Value) gives me an error. I am using SQL 2000.
|||Try the code that I gave above. My output from running the statementselect DATENAME(m, @.CurrentDate) + ' ' + DATENAME(yy, @.CurrentDate)
is:
Column1
-
April 2006
No rows affected.
(1 row(s) returned)
That gives the month name (not number), as you requested...|||Have a look at:
http://msdn2.microsoft.com/en-US/library/ms174395(SQL.90).aspx
It's the documentation for the TSQL DATENAME command.|||
try the following
Switch(Month(Parameters!BeginDate.Value)=01,"January" & Year(Parameters!BeginDate.Value),Month(Parameters!BeginDate.Value)=02,"Feb" & Year( Parameters!BeginDate.Value) )
|||The DATENAME function should also work in SQL Server 2000 - have a look here:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_da-db_1dph.asp
Also have a look at this article for some further examples:
http://www.sqljunkies.com/Article/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk
No comments:
Post a Comment