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 datetime

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2009-12-06 : 01:55:41
1.
i want that my calculate members (cdate(date())) it is called Today
will be in format mm/dd/yyyy

2.i have a measure Mydate of type varchar , i want it will be in format mm/dd/yyyy


rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-06 : 04:59:56
HI

Try this...

CREATE TABLE #TEMP(ID INT IDENTITY(1,1), DATE VARCHAR(12))

INSERT INTO #TEMP

SELECT '11-05-1983'

SET DATEFORMAT MDY -- Month, Date, Year

SELECT CAST(DATE AS DATETIME) FROM #TEMP

SET DATEFORMAT DMY -- Date ,Month ,Year

SELECT CAST(DATE AS DATETIME) FROM #TEMP

DROP TABLE #TEMP


-------------------------
R...
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-12-06 : 16:30:03
Or in SSRS you can just use the Format attribute in properties and enter the code MM/dd/yy. Make sure you have MM capitals as lower case indicates milliseconds and not Months

John
It's a small world (but I wouldn't want to paint it)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-07 : 02:45:25
quote:
Originally posted by rajdaksha

HI

Try this...

CREATE TABLE #TEMP(ID INT IDENTITY(1,1), DATE VARCHAR(12))

INSERT INTO #TEMP

SELECT '11-05-1983'

SET DATEFORMAT MDY -- Month, Date, Year

SELECT CAST(DATE AS DATETIME) FROM #TEMP

SET DATEFORMAT DMY -- Date ,Month ,Year

SELECT CAST(DATE AS DATETIME) FROM #TEMP

DROP TABLE #TEMP


-------------------------
R...



This question is posted in Reporting Services Forum. So better method is to format in the report intself than in t-sql

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

JCirocco
Constraint Violating Yak Guru

392 Posts

Posted - 2009-12-07 : 08:23:06
quote:
Originally posted by JCirocco

Or in SSRS you can just use the Format attribute in properties and enter the code MMddyy. Make sure you have MM capitals as lower case indicates milliseconds and not Months

John
It's a small world (but I wouldn't want to paint it)



John
It's a small world (but I wouldn't want to paint it)
Go to Top of Page
   

- Advertisement -