Jump to content


Photo

find maximum date from table


  • Please log in to reply
3 replies to this topic

#1 bigfatwallet

bigfatwallet
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 November 2005 - 05:48 PM

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

#2 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 05 November 2005 - 06:06 PM

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

View Post

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


#3 bigfatwallet

bigfatwallet
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 November 2005 - 07:49 PM

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.


#4 happs

happs
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 14 April 2006 - 02:48 PM

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) View Post[/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.
[/quote]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users