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 2000 Forums
 SQL Server Development (2000)
 Converting Date

Author  Topic 

shyamprasad76
Starting Member

38 Posts

Posted - 2001-12-28 : 10:59:01
Hi,

I have to store the date '12/1/2001' as '01-Dec-2001'. I know that the Datename and Datepart could do this. But i am just wondering if there is a single function in SQL server to do this. (Like we have FORMAT in ACCESS).

Also I am concerned about converting the single digit day's ie 1 to '01' , 2 to '02' etc. I could not do this with functions like 'DAY' , 'DATENAME' & 'DATEPART'.

Please help.

Thanks,

Shyam.

tribune
Posting Yak Master

105 Posts

Posted - 2001-12-28 : 12:37:54
PRINT REPLACE(CONVERT(varchar,GETDATE(),106),' ','-')

Hope this helps

-trib

Go to Top of Page

shyamprasad76
Starting Member

38 Posts

Posted - 2001-12-28 : 13:25:55
Thank you very much. It works.

- Shyam.

Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-12-28 : 14:38:28
This is just a technicality, but for anyone new to SQL Server who might be reading these... You can't change the way the date is stored. Only the way it is displayed when retrieved.

--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...
Go to Top of Page
   

- Advertisement -