June 25, 2009 at 2:14 pm
Good day all,
trying to use the code below in order to convert a Date to a numeric datatype.
SELECT My_DATE,
Convert(NUMERIC(8,0),CONVERT(CHAR(50), DATEadd(mm,0, My_DATE),112)) AS CheckDate
from dbo.MyDatabase
GO
However I keep getting the error message "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
I've looked around online for a solution and it was mentioned that I should check for Non-numeric values, which they are as all the reocrds came up when I ran this code:
SELECT My_DATE
from dbo.MyDatabase
WHERE ISNUMERIC(My_DATE)=0
GO
So where do I go from here? How do I go about converting these values to numeric ? any help is greatly appreciated.
Thanks,
Mitch....
June 25, 2009 at 3:10 pm
Try:
SELECT My_DATE
from dbo.MyDatabase
WHERE ISDATE(My_DATE)=0;
That's more likely to catch what you're running into.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 25, 2009 at 3:12 pm
I agree with GSquared. The error is converting to a DATETIME not to integer.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
June 25, 2009 at 3:24 pm
Thanks guys !!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply