Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 31st, 2004, 08:16 PM
Matt71 Matt71 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 21 Matt71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Problem with date formats

I have a visual basic program that is communicating with a SQL Server database. The program is required to store details on staff members including 3 different date fields.

The problem that I am having is that when I input a date in to the database it keeps switching the day and month, going from dd/mm/yyyy to mm/dd/yyyy. I have checked with our IT section and they have said that the server is on the correct date time format for this not too happen.

Additionally the database doesn't seem to be able to take any date where either of the first 2 fields figures are largeer than 12, for example:

13/01/1971 - will cause an error
01/13/1971 - will cause an error also.

12/01/1971 - No error but then when reading from database comes up as 01/12/1971
01/12/1971 - No error but comes back as 12/01/1971

The error that I am getting has to do with the "conversion of a char data type in to a date time format results in an out of range value."

I can successfully convert the string value to a date format in VB but when it comes time to run the SQL statement it produces an error.

Can someone help please!!!!

Reply With Quote
  #2  
Old June 1st, 2004, 08:28 AM
apex apex is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 apex User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Have you tried using dashes? ie 01-01-2004

Also, try passing now() into the DB

Reply With Quote
  #3  
Old June 24th, 2004, 01:51 AM
pookemon pookemon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 3 pookemon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb Handling Date Formats with SQL Server

Just a tip but any time I send dates to SQL I use the format dd MMM yyyy.

This way there can be no confusion as to what part of the date is the day, month and year.

When returning dates in queries you can use CONVERT(DATETIME, <myfield>, 106) to get the date in the above format

Or use CONVERT(DATETIME, <myfield>, 113) to get both the date and time.

And finally use SET DATEFORMAT dmy to tell the server that you wish to enter your dates as dd/MM/yyyy.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Problem with date formats


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway