Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 5th, 2007, 08:25 PM
Friend of Wrox
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default selecting date and previous dates

I have a database with an event date. I need to select the latest date and the varying amount dates previous to this. I came up with this but was
wondering if there would be a more efficient way to do this.

SELECT display_date FROM myDB WHERE display_date
AND (SELECT MAX(display_date) FROM myDB)
ORDER BY display_date

Example: Data in database
2004-05-27 00:00:00
2004-05-25 00:00:00
2004-05-26 00:00:00

2006-09-27 00:00:00
2006-09-25 00:00:00
2006-09-29 00:00:00
2006-09-28 00:00:00

2005-09-26 00:00:00
2005-09-25 00:00:00
2005-09-27 00:00:00
2005-09-28 00:00:00

Content Needed To Display and ordering
2006-09-25 00:00:00
2006-09-27 00:00:00
2006-09-28 00:00:00
2006-09-29 00:00:00

Many Thanks
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Previous Date in vb.net kostaskir VB How-To 1 August 31st, 2007 09:21 AM
Needs to get previous date from the given date balakrishna Java Basics 1 April 23rd, 2007 05:25 AM
How to get previous date? rupen Javascript How-To 1 June 26th, 2006 10:57 PM
Problem with selecting data between two dates serf SQL Language 1 January 18th, 2006 01:16 PM
Selecting Data Based on Todays Date worshiploud Classic ASP Basics 2 June 29th, 2003 07:55 PM

All times are GMT -4. The time now is 12:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.