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
 Transact-SQL (2000)
 check data format validity

Author  Topic 

rbohaty
Yak Posting Veteran

71 Posts

Posted - 2006-12-05 : 15:47:57
I have a table with a date column and want to verify that all data in the column is the correct format mm/dd/yyyy. Is there a script I can run on the table /columns to verify all data conforms to the format?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-05 : 15:52:39
You cannot do this!
It does not matter which format the date is presented in QA, EM or SSMS! The date is just a representation of a fraction number where the integer part is the number of days passed since 1 January 1900, and the fraction is the number of 1/300 seconds passed since midnight that day.

Leave it to the front end to do the date formatting.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-05 : 15:54:00
But if the system you are handling is badly planned by storing the dates as VARCHAR (datetime is always to prefer), use this

set dateformat mdy
select * from yourtablenamehere where isdate(yourcolumnnamehere) = 0


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-06 : 10:38:20
1 Use always DATETIME datatype
2 It is front end where you should show that format

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-06 : 10:42:29
quote:
Originally posted by Peso

But if the system you are handling is badly planned by storing the dates as VARCHAR (datetime is always to prefer), use this

set dateformat mdy
select * from yourtablenamehere where isdate(yourcolumnnamehere) = 0


Peter Larsson
Helsingborg, Sweden


ISDATE is like ISNUMERIC not reliable

Select ISDATE('2000'),ISDATE(2000)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -