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


Akshay PhadkeRank #161 · 14.6K reputationPosted May 29, 2016, 11:27 PM EDT
Ashiwani SharmaRank #5,816 · 285 reputationPosted May 30, 2016, 12:28 AM EDT
Pawan Vaish25 reputationPosted May 30, 2016, 2:32 PM EDT
Ranjit Kanojia59 reputationPosted May 31, 2016, 2:24 AM EDT
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.
SELECT cast(NULLIF(a.[PAYOFF DATE],'') AS DATE)