By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,413 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,413 IT Pros & Developers. It's quick & easy.

Date format

Manikgisl
P: 37
hi

any help me format the date in back end

In sql back end have so many formats for date


i want make into single format while retriving in sql


Any possibility is there ??

for eg:
in the back end i have following dates
18-11-2008 2:35:19 PM
11-18-2008 2:35:19 PM
18/11/2008 2:35:19 PM
11/18/2008 2:35:19 PM


To make in Specific Format to Single format


its possible
Nov 18 '08 #1
Share this Question
Share on Google+
3 Replies


ck9663
Expert 2.5K+
P: 2,878
You will have a problem with 09/08/2008. This could be interpreted in two ways. Sept 8 or Aug 9.

Here are some of my notes regarding dates.

Try analyzing the pattern and see if it's mm/dd/yyyy or dd/mm/yyyy. Based on your example it's mixed. Try to make it a single format first then convert the column to smalldate or datetime, depending on your requirement.For that read my old notes, here

-- CK
Nov 18 '08 #2

Manikgisl
P: 37
You will have a problem with 09/08/2008. This could be interpreted in two ways. Sept 8 or Aug 9.

Here are some of my notes regarding dates.

Try analyzing the pattern and see if it's mm/dd/yyyy or dd/mm/yyyy. Based on your example it's mixed. Try to make it a single format first then convert the column to smalldate or datetime, depending on your requirement.For that read my old notes, here

-- CK

But the problem is we have dates in Varchar instead Datetime

While Converting Varchar To Datetime All four formats are unable to

Convert

ie

select Convert(Datetime,'18-11-2008 2:35:19 PM',102) -- error


"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."

select Convert(Datetime,'11-18-2008 2:35:19 PM',102) ok


select Convert(Datetime,'18/11/2008 2:35:19 PM',102) Error

"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."

select Convert(Datetime,'11/18/2008 2:35:19 PM',102) ok
Nov 19 '08 #3

ck9663
Expert 2.5K+
P: 2,878
Double post. I replied on your new post, here

-- CK
Nov 19 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.