-
convert and isdate
I have a text file I have to load an massage the data. There is a date field which is a varchar where I do a conversion. As of 7-19 the conversion to inline sql stoppped working. Look at example below
declare @dob varchar(08)
set @dob = '02291956'
select convert(datetime,Right(@dob,4) + Left(@dob,4)) as dob
select convert(datetime,Right(dob,4) + Left(dob,4)) as dob from marylanddoc
The 1st statement works, however the select statement now fails with a conversion failure. ANyone seen this pop up. Just as an FYI, I do have 20 records that were processed with a leap year 0229 date that were created by this process before 7/19
-
-
Server: Msg 242, Level 16, State 3, Line 4
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
I checked the table these records get inserted into, and there were previous values that were leap year dates that worked. Just stopped working Thursday.
It looks like the conversion on the defined variable works fine, but the conversion on at the table level fails
-
Any strange value in source column?
-
No and then I tried this
declare @dob char(08)
set @dob = '02291956'
select isdate(convert(datetime,Right(@dob,4) + Left(@dob,4))) as dob
select isdate(convert(datetime,Right(dob,4) + Left(dob,4))) from marylanddoc
The isdate for the @dob returns 1, it fails when reading the char(08) field. Any other value in this char field converts, except for the leap year
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|