Jump to content

Getting minimal date in my table mysql


sugan
 Share

Recommended Posts

Hi,I want to retrieve minimal date from the data i have entered in my database. Say that i have

2008-12-12 Anu2008-1-12 rone2007-12-12 barr2008-2-12 rone
Now i want to know which is the minimal date here, so it should give me 2007-12-12.How to write a query to it!Regards,Suganya
Link to comment
Share on other sites

I'm guessing the entire string ("2008-12-12 Anu") is stored in a single field? That doesn't seem like a good idea, but okay. Are you using PHP? Load the string into a variable like $date. Then do something like this:$pattern = '/\d+-\d+-\d+/';preg_match($pattern, $date, $min);Your minimum date should be in $min[0].

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...