satheesh babu

satheesh babu

  • NA
  • 128
  • 312.1k

conversion date problem

Dec 30 2008 1:39 AM

Hi all,

Here i created a table with column date1 with varchar(50) data type. and i am storing

the values like dd/mm/yyyy.

now i am comparing this column with below code

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)))

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 membershipregistration

where 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


Answers (1)