Im using MSSQL 2008 and have a field called AbsoluteDates that contains data in numeric for mat, for example
AbsoluteDates
20051216
20051217
20051218
10000
90
600
What i need to do is a “Select” statement that will ignore any date thats not 8 numbers in lenth and then convert the results to a datetime ,aso it should be like a case statement becuase i need to produce something when the length is not 8 charectors , for example the word ” NotValid”
so for example , Select AbosluteDates from Calendar where lenth = 9 would give me the following results if i had the same data as above.
AbsoluteDates
2005-12-16 00:00:00.000
2005-12-17 00:00:00.000
2005-12-18 00:00:00.000
NotValid
NotValid
NotValid
You can cast to varchar then a datetime like this and then back to a varchar:
Just replace the hard-coded search with your actual data table