SELECT * FROM WeekMaster WHERE CAST(GETDATE() AS DATE) BETWEEN CAST(DateFrom AS DATE) AND CAST(DateTo AS DATE)
AND CourseId=95
I am using above sql query for cast date and on the basis of this i get details from table but when i insert '1900-01-01' as date in date column query unable to read that raws field ?
please help if possiable or suggest me to resolve this

Ranjit KanojiaPosted May 31, 2016, 6:24 AM
mm/dd/yyyyformat just cast it as DATE.For
1900-01-01values, since you are converting from a string data type to Date, String datatype can have Empty strings but Date datatype cannot have empty date values, It can have either a date value orNULLvalue.Therefore you need to convert the empty string to nulls before you convert it to date. 1900-01-01 is just a default value sql server puts in for you because Date datatype cannot have an empty value.
You can avoid having this sql server default value by doing something like this.
Pawan VaishPosted May 30, 2016, 6:32 PM
Ashiwani SharmaPosted May 30, 2016, 4:28 AM
Akshay PhadkePosted May 30, 2016, 3:27 AM