SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Convert DD-Mon-YYYY to DD/MM/YYYY


Convert DD-Mon-YYYY to DD/MM/YYYY

Author
Message
arthi.anan
arthi.anan
SSC-Enthusiastic
SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)

Group: General Forum Members
Points: 148 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...
peterdru401
peterdru401
Valued Member
Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)

Group: General Forum Members
Points: 71 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
arthi.anan
arthi.anan
SSC-Enthusiastic
SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)

Group: General Forum Members
Points: 148 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
peterdru401
peterdru401
Valued Member
Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)

Group: General Forum Members
Points: 71 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]
ACinAZ
ACinAZ
Old Hand
Old Hand (365 reputation)Old Hand (365 reputation)Old Hand (365 reputation)Old Hand (365 reputation)Old Hand (365 reputation)Old Hand (365 reputation)Old Hand (365 reputation)Old Hand (365 reputation)

Group: General Forum Members
Points: 365 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!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search