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
 Transact-SQL (2005)
 convert date to varchar

Author  Topic 

shahab03
Starting Member

28 Posts

Posted - 2008-05-27 : 14:41:16
I have a datetime column and I would like to update another column in the same table with the varchar value of date. e.g. date column has 06-08-2008 as a value. I would like to have the same value in the varchar field.

wondering which function can I use to accomplish this task?

thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-27 : 14:45:52
You can use CONVERT or CAST functions although I believe you can just let it implicitly convert it for you since it's from datetime to varchar.

But why would you want to store dates in a varchar column?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

shahab03
Starting Member

28 Posts

Posted - 2008-05-27 : 15:10:27
its to build a cube...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-27 : 15:13:04
Can't cubes handle date/time data in a datetime column?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

shahab03
Starting Member

28 Posts

Posted - 2008-05-27 : 15:13:41
should be able to. but thats how we are storing them.
Go to Top of Page
   

- Advertisement -