Subject: Date Formats
Posted By: carumuga Post Date: 12/28/2006 6:41:13 AM
Hi,

I have stored my dates in a OrderDate field in the following fashion
Assuming that its a varchar field

OrderDate

2006-10-09   
10-09-06     
09-10-2006   
10 Sep 2006  

I need a program which should outputs the format as shown below

YYYY-MM-DD
DD-MM-YY
MM-DD-YYYY
DD MON YYYY



Chandru
Reply By: Jeff Moden Reply Date: 12/28/2006 7:53:29 AM
Why?  They're already in those formats.  Do you mean something else for the output?

--Jeff Moden
Reply By: carumuga Reply Date: 12/28/2006 8:17:56 AM
Say for Eg.
1. OrderDate - 12/10/2006
2. OrderDate - 09/05/06

I need to verify whether OrderDate is in this format - dd/mm/yyyy
As in 2nd eg. my format should be mm/dd/yy

System should verify whether the date stored in the database is valid date of particular format.








Chandru
Reply By: Jeff Moden Reply Date: 12/28/2006 9:33:32 AM
There's no way to tell if a date like 11/12/2006 is in the mm/dd/yyyy format or the dd/mm/yyyy format unless it's an absolute given that 11/12/2006 will ALLWAYS be in the mm/dd/yyyy format and that 11/12/06 (has only a 2 digit year) will ALWAYS be in the dd/mm/yy format.  Can you make that guarantee in your data?

--Jeff Moden
Reply By: robprell Reply Date: 1/2/2007 6:20:27 PM
you can do something like that using case statements, for example check if the fifth character is a "-" then you know your using CCYY-MM-DD.  You have to add conditions that cover all your possible types though.  Also if the third and the seven characters are space then your "DD MON YYYY".  Can get very complexed depending on how many date formats your dealing with.


Go to topic 54270

Return to index page 402
Return to index page 401
Return to index page 400
Return to index page 399
Return to index page 398
Return to index page 397
Return to index page 396
Return to index page 395
Return to index page 394
Return to index page 393