Hi
all,Here i created a
table with column date1 with varchar(50) data type. and i am storingthe
values like dd/mm/yyyy.now i am comparing this
column with below codeselect
date from membershipregistrationwhere
convert(datetime,date,103) between (select(convert(datetime,'01/12/2008',103))) and (select( convert(datetime,'31/12/2008',103)))but its giving below error after showing result
set.The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value
and then i tried storing the values like yyyy/dd/mm and then i compared the values with below
statement and its working fine.
select
date from membershipregistrationwhere
convert(datetime,date,103) between (select(convert(datetime,'2008-01-12',103))) and (select( convert(datetime,'2008-24-12',103)))but i want
to store the values like dd/mm/yyyy only.Please give me the solution
.thank you
Blocked AccountPosted Dec 30, 2008, 2:25 AM
select date from membershipregistration
where
convert(datetime,date,103) between (select(convert(datetime,'01/12/2008',103))) and (select( convert(datetime,'31/12/2008',103)))This code will also work if u will take care about the data u have stored in the date column. I mean to say if u store in the date column 31/11/2008 and try it to convert into the datetime format, then u will get the same error as u got earlier because it's not a valid date.
I think u got my point.