Jump to content

find maximum date from table


bigfatwallet

Recommended Posts

Good evening all.

 

I have a table that has a column called enddate and is of datatype date. (The dates will always be in the future.)

 

I would appreciate any help with the following:

 

1) The next date (in date terms - not table terms)

2) The maximum date

 

Can you please also advise how I get this to output to a browser.

 

Many thanks in advance

Link to comment
Share on other sites

Good evening all.

 

I have a table that has a column called enddate and is of datatype date. (The dates will always be in the future.)

 

I would appreciate any help with the following:

 

1) The next date (in date terms - not table terms)

2) The maximum date

 

Can you please also advise how I get this to output to a browser.

 

Many thanks in advance

315128[/snapback]

1st

SELECT * FROM table_name ORDER BY enddate DESC LIMIT 1

2nd

SELECT * FROM table_name WHERE enddate>now() ORDER BY enddate ASC LIMIT 1

Link to comment
Share on other sites

  • 5 months later...

Just to clarify ..

 

I have a table with a date column in the format of YYYY-MM-DD for a database of events. Each event has a date and I want the site I am working on to get the NEXT event according to today's date. Would this code work for this also ?

 

Thanks in advance

 

- Alex

 

[!--quoteo(post=315172:date=Nov 5 2005, 08:49 PM:name=bigfatwallet)--][div class=\'quotetop\']QUOTE(bigfatwallet @ Nov 5 2005, 08:49 PM) 315172[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Thank you so much.

 

I can't believe I didnt think of that myself, I was trying min and max and all sorts of sutff! lol

 

Once again thanks.

 

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.