I have a MySQL database which has a column called "Date", i want the results to be ordered in date order so i do:
$query="SELECT * FROM complete ORDER By Date";
The dates are entered in the format DD/MM/YYYY
When the results are displayed it will only list them by oder of DD, how can i make it order them by DD/MM/YYYY
Thanks
Sort by date PHP/MySQL
Moderator: General Moderators
-
thedarkdestroyer
- Forum Newbie
- Posts: 9
- Joined: Thu Sep 28, 2006 9:27 am
Date Format in a Table
When I am creating my table would a command like this be sufficient to create the Date column in date format:
create table log(ID int(10) not null auto_increment primary key, FirstName VARCHAR(30), LastName VARCHAR(30), DateField DATE dateformat( '-%d -%m -%y');
when I try to create this table, i get an error message, ......the right syntax to use near'dateformat('-%d -%m -%y'))' at line 1
create table log(ID int(10) not null auto_increment primary key, FirstName VARCHAR(30), LastName VARCHAR(30), DateField DATE dateformat( '-%d -%m -%y');
when I try to create this table, i get an error message, ......the right syntax to use near'dateformat('-%d -%m -%y'))' at line 1
- itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
- Contact:
try:
Code: Select all
$query="SELECT `Date` as dat FROM complete ORDER By dat";