Hi Experts,i have to write a where condition where i need to compare string with datei have 2 columns FROMDATE and TODATE with datatype varchar(9)the strings in the columns looks like YYYYMMDD+'1' or YYYYMMDD+'2' here 1 is Am and 2 is PMi.e., 201401011 or 201401012so i need to chop off last character before using them in WHERE condition.now i need to write a where condition like [if todays date is in between fromdate and todate columns then return rows.if FROMDATE column is null it should take minimum date 1900/01/01 if TODATE is null then date should be 9999/01/01the query i wrote is select * from Table where ISNULL(SUBSTRING(VALIDTO,1,8),'19000101') > = getdate() AND ISNULL(SUBSTRING(VALIDTO,1,8),'99991231') < convert(varchar, getdate(), 112)but it shows no dataplease help me pass through thisThank you.
↧