Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2006, 07:41 AM
Authorized User
 
Join Date: Dec 2006
Location: chennai, tn, India.
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date Formats

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
__________________
Thanks,
Chandra
 
Old December 28th, 2006, 08:53 AM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Why? They're already in those formats. Do you mean something else for the output?

--Jeff Moden
 
Old December 28th, 2006, 09:17 AM
Authorized User
 
Join Date: Dec 2006
Location: chennai, tn, India.
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old December 28th, 2006, 10:33 AM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

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
 
Old January 2nd, 2007, 07:20 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Date Formats tracyamgray XSLT 5 July 12th, 2006 10:17 PM
Trouble with date formats DrewMills Access VBA 3 March 7th, 2005 06:22 PM
displaying different date formats using LCID leo_vinay Classic ASP Basics 1 November 26th, 2004 07:17 PM
SQL and Date Formats al_bllinky Access 3 August 28th, 2003 08:45 AM
Date formats in the forum Crispin Horsfield Forum and Wrox.com Feedback 1 August 3rd, 2003 08:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.