Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Format Date

Author  Topic 

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2008-04-18 : 09:34:57
Hi, I need help formating a date.

my current value is 20080404
i want it to be formated as 04/04/2008

i got this example off the net but the expreesion does not moan but it displays "#error#"

=Format(CDATE(First(Fields!Received.Value, "CFG")),"dd/mm/yyyy")

Please Assist!

Regards

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-18 : 09:45:20
Is this reporting services? Then use FormatDateTime() function.Look into BOL for syntax.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-04-18 : 09:57:10
Yet another example of why not using the correct data types makes simple things incredibly difficult.

Chances are, you have an invalid value in your column, such as 20081400 or something like that. You'll need to query your database to find out for sure.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2008-04-21 : 03:10:46
Thank You for the assistance but i just cant get it going.

I checked the data by set it to only 5 records.

It tried the following but no luck.

=Formatdatetime(CDATE(First(Fields!Received.Value, "CFG")),"dd/m/yyyy")
=Formatdatetime(First(Fields!Received.Value, "CFG"),"dd/mm/yyyy")
=Formatdatetime(First(Fields!Received.Value, "CFG"),1)

Value is 20080404 only

Please Assist

Regards
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-21 : 03:21:46
Is the column DATETIME?
Is the column VARCHAR?
Is the column INT?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2008-04-21 : 03:32:09
varchar(10)
Go to Top of Page

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2008-04-21 : 04:04:26
Hi,

Thank You all as done the formating in my sql.
I really appreciate the assistance!

format:
select
replace(convert(varchar, Received, 104), '.', '/') as Received
from
(select
cast(e.CreateDate as datetime) as Received


Regards
Go to Top of Page
   

- Advertisement -