Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Convert DD-Mon-YYYY to DD/MM/YYYY Expand / Collapse
Author
Message
Posted Wednesday, October 24, 2012 10:40 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, February 13, 2013 6:23 AM
Points: 20, Visits: 55
Hi experts,
I have a table called temp in which i have date columns as dt_of_birth [varchar](15),dt_of_joining [varchar] (15).The dates are already stored in the format as DD-Mon-YYYY. Its the employees records

Now i have to convert these dates as datetime and store it another table employees as DD/MM/YYYY.

How do i fetch these dates into a query and convert and store it in the other table?

Thanks in advance...
Post #1376768
Posted Thursday, October 25, 2012 12:24 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, April 16, 2013 8:34 AM
Points: 23, Visits: 128
This should get you what you are looking for. I don't know if there is a better way (I'm sure there is tho) but this seems to work OK for me.
view sourceprint?

1
SELECT replace(convert(varchar(50),scheduleTime,106),' ','-') as scheduleTime
Post #1376795
Posted Thursday, October 25, 2012 3:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, February 13, 2013 6:23 AM
Points: 20, Visits: 55
The date which i give as '10-Aug-2010' is converted and stored in the table as '2010-08-10'
but i want the date to be stored as '10/08/2010'
I tried with your it does the conversion but i wanted in this format...
Please help
Post #1376874
Posted Thursday, October 25, 2012 3:59 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, April 16, 2013 8:34 AM
Points: 23, Visits: 128
In this case u may refer this link to solve ur query

[url=http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/1aa3b0df-8d9e-489d-90f2-d441bb241b8e/][/url]
Post #1376876
Posted Friday, October 26, 2012 9:06 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 1, 2014 3:27 PM
Points: 109, Visits: 957
Posting the same question multiple times doesn't help you get to the right answer, it just fragments the responses you get.

You don't store dates in SQL Server formatted as anything. That's a display function. Date/time values are stored as decimal values. Do a search of the BOL for dates, and the CONVERT and CAST functions.

Don't store dates as strings!
Post #1377663
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse