Showing posts with label saved. Show all posts
Showing posts with label saved. Show all posts

Sunday, February 12, 2012

casting integer to month

Hi,

in the database that we use for learning reporting services a month is saved as an integer in a column. In the report I would like to have the month fully written istead of the numbers 1 to 12. Is this possible with the CAST function or the CONVERT function, I can't find the exact information in the msdn.

greetings

Hi,

as far as I know, there is only DATENAME which produces the name of the Month, perhaps you make a function out of that:

CREATE FUNCTION MonthName
(
@.Month TINYINT
)
RETURNS VARCHAR(20)
AS
RETURN (Select DATENAME(mm,DATEADD(dd,-1,DATEADD(mm,@.Month,0))))

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

|||Creating a new function would do the trick indeed but I am working in a limited version of Visual Studio that only allows us to do reporting services...
|||I tried to use the function DATENAME in the field where the month should appear. 'Fields!maand.Value' is the value from the database.

=DATENAME(mm,DATEADD(dd,-1,DATEADD(mm,Fields!maand.Value)))
|||oh and it didn't worked ;)
|||Oh it's easy
the function is:

=MonthName(Fields!maand.Value)
you can place it an your tabel in your layout
it's a visual basic function apparently
|||My post was TSQL syntax, if you want to format that inyour code (VBScript) you have to do something like =FORMAT("MM",yourdate) or =MONTH(Yourdate), sorry but I don′t have the syntax right in my mind, perhaps you can check the help file form the report builder.

HTH, Jens Suessmeyer.

Friday, February 10, 2012

Cast and convert

How do I convert a colomn that is of data type varbinary to varchar so that the hex values saved there are shown as readable text usable with crystal reports.In SQL2K there is a function
master.dbo.fn_varbintohexstr (@.pbinin varbinary(8000) ) returns
nvarchar(4000)
Don't know why @.pbinin is varbinary(8000), since nvarchar(4000) can only
handle 2000 bytes!
It's just pretty simple code for doing the translation; if nvarchar(4000)
doesn't suit you, the source for the function is easy to modify (to create a
different function!)
"shaun" <shaun@.discussions.microsoft.com> wrote in message
news:F8EAF61A-2844-4C7C-BE22-46C72B9A7A77@.microsoft.com...
> How do I convert a colomn that is of data type varbinary to varchar so
that the hex values saved there are shown as readable text usable with
crystal reports.