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
 General SQL Server Forums
 New to SQL Server Programming
 Convert Date

Author  Topic 

nguyenl
Posting Yak Master

128 Posts

Posted - 2008-08-13 : 18:46:06
Hi,

How do I select a column and at the same time convert the column with this date format: mm/dd/yy?

Thanks,

nguyenl
Posting Yak Master

128 Posts

Posted - 2008-08-13 : 18:52:41
How about this format?

mm/dd/yyyy

Thanks
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-13 : 19:03:23
Use the CONVERT function with the appropriate style. For instance: SELECT CONVERT(varchar(10), GETDATE(), 101)

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

Subscribe to my blog
Go to Top of Page

nguyenl
Posting Yak Master

128 Posts

Posted - 2008-08-13 : 19:40:33
It works when I preview it, but I use an SSIS package to export it to text file it does not work. The format is still there. Do you know why?

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-14 : 01:13:50
then use derived column task in ssis to format it
Go to Top of Page

nguyenl
Posting Yak Master

128 Posts

Posted - 2008-08-14 : 11:50:19
In my SSIS package I have a DATA Flow Task that consists of

OLE DB SOURCE - DTACONVERSION -DERIVED COLUMN - FLAT FILE DESTINATION

In my DERIVED COLUMN TASK I have a the Expression Datepart("year", getdate()) just to see if it chages the date if I was to export it to a text file. It doesn't seem to work. The date still exports as

1905-06-30 00:00:00. Please help.
Go to Top of Page
   

- Advertisement -