467,915 Members | 1,383 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

Date format

Manikgisl
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
  • viewed: 1558
Share:
3 Replies
ck9663
Expert 2GB
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
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 2GB
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.

Similar topics

15 posts views Thread by Simon Brooke | last post: by
4 posts views Thread by Richard Hollenbeck | last post: by
5 posts views Thread by Macca | last post: by
12 posts views Thread by Assimalyst | last post: by
20 posts views Thread by andreas | last post: by
30 posts views Thread by fniles | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.