Retrive Data between Two Varchar Dates from MySql -


hello using mysql database.i have 1 table employee. employee table description given below.

emp_id int(10),emp_name varchar(255),dob varchar(120)  

and store employee dob in

dd-mmm-yyyy formate (21-may-1990) 

now want employee dob between 01-may-1990 31-may-1990.

kindly let me know how data between 2 varchar date

i have edit question. date formate "dd-mmm-yyyy".

thank you.

since values stored string, need convert it. mysql has built in function called str_to_date.

select emp_id, emp_name tablename str_to_date(dob,'%d-%m-%y') >= '1990-05-01'        , str_to_date(dob,'%d-%m-%y') <= '1990-05-31' 

however, using function on column doesn't use index , decrease performance on large tables. solution use correct datatype date , create index on it.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -