Jump to content

[SOLVED] How to get details between the range


gokhul

Recommended Posts

hello,

 

can anyone tell me how to get the result between the range of the following dates.

 

name      age    gender    joiningdate      leavingdate

xxx        10      male      04/23/09        05/22/09

yyy        11    female      01/02/09        08/02/09

zzz        12      male      04/26/09        04/28/09

 

How should I write the select statement such that I can get the details between any two given dates?

 

Please help me.

Link to comment
Share on other sites

What type of data is joiningdata and leavingdate? I hope it's of some date format - DATE, TIMESTAMP, etc. I don't think MM/DD/YYYY is a MySQL date-formatted string. I would not use varchar and use TIMESTAMP or DATE or DATETIME. That should help when selecting.

Link to comment
Share on other sites

After you change your columns to a DATE data type (the format they are now cannot be directly used in a date comparison) what exactly are you looking for? Provide an example. Are you looking for the values in your table that are completely within two given dates or are you looking to match any that have any overlap at all with two given dates?

Link to comment
Share on other sites

Yes..I am looking for the entire details in my database between any two given dates.

 

I have the data in the following format.

 

patient    age    gender      consultdate

1            20      male          04/23/09

2            30      male          04/30/09

3          10        female        05/19/08

 

 

 

Sorry for giving the wrong data above.

Now, If i say the range as 05/19/08 and 04/23/09....i should get all the three results.

 

Can you tell me what should be my select statement.

 

Regards.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.