MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

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 Dev Shed Forums Sponsor:
  #1  
Old August 2nd, 2004, 11:21 AM
narmi2 narmi2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 162 narmi2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 47 m 14 sec
Reputation Power: 5
setup date format sql server 2000

Does anyone know if its possible to configure sql server 2000 so it reads in the date in a different format. Right now, it takes the date in the following format month day year. I want it to take in day month year instead.

I am using asp.net and that is properly configured to give day month year, but then this date is sent to sql server, i get into problems

please help

Reply With Quote
  #2  
Old August 2nd, 2004, 02:20 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,953 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 15 h 36 m 41 sec
Reputation Power: 1024
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
  #3  
Old August 2nd, 2004, 03:10 PM
narmi2 narmi2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 162 narmi2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 47 m 14 sec
Reputation Power: 5
Thanks

But does that not set the date only for that sql statement.

I was looking for something more permanent. for example set it to uk date once and thats its. after that it will understand uk dates

is that not possible?

Reply With Quote
  #4  
Old August 3rd, 2004, 03:48 AM
narmi2 narmi2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 162 narmi2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 47 m 14 sec
Reputation Power: 5
Anyone know why this does not work?

INSERT INTO mytable (CONVERT(nvarchar(20), [date], 113) AS date) VALUES (30/04/2004) where [name] = 'jo'

i want to insert 30/04/2004 into the database but it ends up like this 04/30/2004.

I want it to keep its formatting as 30/04/2004

Reply With Quote
  #5  
Old August 3rd, 2004, 05:11 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,953 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 15 h 36 m 41 sec
Reputation Power: 1024
that doesn't work because it's invalid syntax (i'm suprised it runs at all)

when you say INSERT INTO tablename ( columns ) you can only have column names in the parentheses

and even if you were able to run it, 30/04/2004 is not a valid date string, it has to be '30/04/2004'

finally, no matter how you are able to get a date value into a table column, when you display it, it will display in the default format

so if you want a particular format, you can use CONVERT to display it

Reply With Quote
  #6  
Old August 4th, 2004, 01:09 PM
narmi2 narmi2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 162 narmi2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 47 m 14 sec
Reputation Power: 5
thanks, figured it out.

Reply With Quote
  #7  
Old October 11th, 2004, 06:28 PM
mjmcmahon mjmcmahon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 mjmcmahon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Pray tell, what is the solution?

Hi Narmi2,

I've been dealing with this date formatting issue for some time in a web based document management system that I work on. I was just wondering if you could elaborate on the solution you came to for this problem.

Thanks in advance.

Reply With Quote
  #8  
Old October 13th, 2004, 01:38 PM
msp_cbe msp_cbe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Gaborone, Botswana
Posts: 12 msp_cbe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m
Reputation Power: 0
Thumbs up

Hi!

Use the format 'dd-MMM-yyyy' always to form the DML statements. You wont face any problems in inserting or updating values in a date field. For e.g.:
Code:
INSERT INTO MST_EMP(EMP_DOB) VALUES('25-MAR-2000')

To form the same statement in VB.NET:
Code:
dDOB = Now().AddYears(-30)
sQuery = "INSERT INTO MYTABLE(MYDATE) VALUES('" & FORMAT(dDOB,"dd-MMM-yyyy") & "')"

and use it to execute.

Hope this will help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > setup date format sql server 2000


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 6 hosted by Hostway
Stay green...Green IT