Quick! Date Conversion 
Author Message
 Quick! Date Conversion
I need to convert the dates in a table from yyyy-mm-dd to mm/dd/yyyy.  How
can this be done?  All I have been able to find is how to convert datetime
fields and I haven't been able to get that to work for what I need.

Thanks.



Tue, 09 Dec 2003 05:38:25 GMT
 Quick! Date Conversion

Are you saying you want to change the underlying data in the table? If so,
then I assume you are storing your dates in a CHAR type column and are not
using a datetime or smalldatetime column.

To change the dates for a character column, do something like this:

Update table
Set column = substring(column, 6, 2) + '/' + substring(column, 9, 2) + '/' +
substring(column, 1, 4)

If you are dealing with a datetime / smalldatetime column you can either
format the column value on the client side, or use the CONVERT function:




--
David Gugick
Intrinsic Design, Inc.
Coefficient - Database Analysis for Microsoft SQL Server
http://www.idisoft.com


Quote:
> I need to convert the dates in a table from yyyy-mm-dd to mm/dd/yyyy.  How
> can this be done?  All I have been able to find is how to convert datetime
> fields and I haven't been able to get that to work for what I need.

> Thanks.



Tue, 09 Dec 2003 06:27:35 GMT
 Quick! Date Conversion
Thanks, David.  That did the trick.


Quote:
> Are you saying you want to change the underlying data in the table? If so,
> then I assume you are storing your dates in a CHAR type column and are not
> using a datetime or smalldatetime column.

> To change the dates for a character column, do something like this:

> Update table
> Set column = substring(column, 6, 2) + '/' + substring(column, 9, 2) + '/'
+
> substring(column, 1, 4)

> If you are dealing with a datetime / smalldatetime column you can either
> format the column value on the client side, or use the CONVERT function:




> --
> David Gugick
> Intrinsic Design, Inc.
> Coefficient - Database Analysis for Microsoft SQL Server
> http://www.idisoft.com



> > I need to convert the dates in a table from yyyy-mm-dd to mm/dd/yyyy.
How
> > can this be done?  All I have been able to find is how to convert
datetime
> > fields and I haven't been able to get that to work for what I need.

> > Thanks.



Tue, 09 Dec 2003 06:47:10 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Eternity date/date conversion

2. Julian Date Conversion to SQL Date:

3. Date Conversion, String to java.util.Date from Access DB

4. Date to Julian date conversion

5. week(int) to date(date) conversion in SQL

6. week(int) to date(date) conversion in SQL

7. quick access2000 conversion question

8. QUICK REPORT CONVERSION (D1 to D3), HELP!!!

9. Quick Reports Conversion

10. How to pass two dates to a query tbl into a quick report form

11. quick question - take 2 time/date stamping


 
Powered by phpBB® Forum Software