Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How To Convert Date Type In The Table

Author  Topic 

iquttaineh
Starting Member

4 Posts

Posted - 2005-06-06 : 04:20:05
Dear all,

My problem is like that:-
I have inserted many rows in MM/DD/YYYY format, but later on i had to change the format into DD/MM/YYYY, so when i do an update on any of the old rows it will generate an error on the date.

Does anyone know any update statement that change the format without any problem ??? All i want is to replace the day with the month and vice versa.

Best regards

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-06-06 : 04:40:41
what's your update statement and error encountered?

--------------------
keeping it simple...
Go to Top of Page

iquttaineh
Starting Member

4 Posts

Posted - 2005-06-06 : 05:11:03
The error message is:-

The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
Go to Top of Page

raclede
Posting Yak Master

180 Posts

Posted - 2005-06-06 : 05:14:20
user convert: try this

Error:

INSERT INTO sample (mydate)
SELECT '4/1/2005' UNION ALL
SELECT '30/6/2005'

Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.

Correct:
INSERT INTO sample (mydate)
SELECT '4/1/2005' UNION ALL
SELECT CONVERT(datetime,'30/6/2005',103)


"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside. "

raclede
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-06-06 : 05:56:32
SET DATEFORMAT dmy

rockmoose
Go to Top of Page
   

- Advertisement -