Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:10 PM.


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