Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order by date

Status
Not open for further replies.

7724

Programmer
Feb 25, 2005
28
GB
Hi,

I'm trying to select data from my database to output on a php page:

PHP:
SQL = "SELECT * FROM `tablename` ORDER BY date";

Now this works fine, but what I want is instead of selecting it by date, I want it to look in a variable named $dateone for all records and order it by the date there.

Now what I do not understand is how the code recognises the date? Say I have one record date as 11th January and another 12th March, surely it would not recognise to put 11th January first? Would it recognise 11/1/05 and 12/03/05 if I inputted that into my variable or not?

Hope that makes sense!

Thanks

Chris
 
PJP uses variables of specific types, such as integer, double, string, and also time (which is a full date).
When you create a date variable you can for example create a time type from a string.
Have a look at the function strtotime() and the faq434-3493 which talks about date compariosons. It will help you understand the matter better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top