Jump to content

Archived

This topic is now archived and is closed to further replies.

bigfatwallet

find maximum date from table

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

×

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.