di99lipe
April 4th, 2007, 09:25 AM
Hey!
I have a problem with a this query:
SELECT ASSIGNMENTID, VESSEL_ETA,
ISDATE(VESSEL_ETA), DATEDIFF(dd, VESSEL_ETA , VESSEL_ETA) FROM tblTRAN
VESSEL_ETA is a varchar(15) in ms sql 2005 and looks like this 20071010
The ISDATE(VESSEL_ETA) returns a 1 that confirms that it is a valid date.
The DATEDIFF should return days between the two dates(this time 0 days) but it gives an error
"Conversion failed when converting datetime from character string."
If I try
SELECT ASSIGNMENTID, VESSEL_ETA,
ISDATE(VESSEL_ETA), DATEDIFF(dd, '20070101' , '20070120') FROM tblTRAN
it works fine but this should be exactly the same as above.
What causes this? Any ideas are appreciated...i am confused :)
Peeweeee
I have a problem with a this query:
SELECT ASSIGNMENTID, VESSEL_ETA,
ISDATE(VESSEL_ETA), DATEDIFF(dd, VESSEL_ETA , VESSEL_ETA) FROM tblTRAN
VESSEL_ETA is a varchar(15) in ms sql 2005 and looks like this 20071010
The ISDATE(VESSEL_ETA) returns a 1 that confirms that it is a valid date.
The DATEDIFF should return days between the two dates(this time 0 days) but it gives an error
"Conversion failed when converting datetime from character string."
If I try
SELECT ASSIGNMENTID, VESSEL_ETA,
ISDATE(VESSEL_ETA), DATEDIFF(dd, '20070101' , '20070120') FROM tblTRAN
it works fine but this should be exactly the same as above.
What causes this? Any ideas are appreciated...i am confused :)
Peeweeee