May 2, 2003 at 2:25 pm
I'm validating raw data in a migration process and need a datetime validation function. Can anyone help?
Developer Developer Developer Developer Developer Developer Developer *jumps around like a moron* Developer Developer
Developer Developer Developer Developer Developer Developer Developer *jumps around like a moron* Developer Developer
May 2, 2003 at 2:30 pm
select * into newtable
where isdate(hopefully_date_field) = 1
Insert into newtable
select field1, case field2
when isdate(hopefully_date_field) = 1 THEN hopefully_date_field
else null
end
Either of these help?
Michelle
May 2, 2003 at 2:41 pm
I was going to use Isdate() but it doesn't work on Datetime types, does it?
Developer Developer Developer Developer Developer Developer Developer *jumps around like a moron* Developer Developer
Developer Developer Developer Developer Developer Developer Developer *jumps around like a moron* Developer Developer
May 2, 2003 at 2:53 pm
create table admin.dbo.temptable
(textdatetime char(16))
insert into admin.dbo.temptable
values('010203 12:00')
alter table admin.dbo.temptable
add field2 datetime
update admin.dbo.temptable
set field2 = textdatetime
where isdate(textdatetime) = 1
select * from admin.dbo.temptable
textdatetime
010203 12:00
field2
2001-02-03 12:00:00.000
It works in this example
Michelle
May 2, 2003 at 3:16 pm
Thanks, but it appears that Isdate() does indeed work on a datetime column.
Developer Developer Developer Developer Developer Developer Developer *jumps around like a moron* Developer Developer
Developer Developer Developer Developer Developer Developer Developer *jumps around like a moron* Developer Developer
May 4, 2003 at 9:55 pm
I'm unclear of what you're trying to do here. You say you need to validate datetime values, but then you mention validating an existing datetime column. If the datetime value was invalid to begin with, it couldn't have been assigned to an actual datetime column. Isdate() will always return 1 for an actual datetime column or variable, unless its value is NULL. So, are you trying to validate a "text" representation of a datetime value before assigning it to an actual datetime column?
Jay Madren
Jay Madren
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply