Jump to content

[SOLVED] Time Sorting


tobeyt23

Recommended Posts

Table Structure:

id	int(10) unsigned	NO	PRI		auto_increment
private	int(1)	NO		0	
hidden	int(1)	NO		0	
title	varchar(200)	YES			
eDate	date	YES			
eDate_end	date	YES			
eTime	varchar(255)	YES			
eTime_note	varchar(255)	YES			
descr	text	YES			
visitor_name	varchar(255)	YES			
college_name	varchar(255)	YES			
location	varchar(255)	YES			
url	varchar(255)	YES			
file	varchar(255)	YES			
team_id	int(11)	YES			
opponent	varchar(255)	YES			
home_away	varchar(4)	YES			
depart_time	varchar(255)	YES			
return_time	varchar(255)	YES			
direction_id	int(11)	YES			
created_by	int(11)	YES			
date_created	datetime	YES			
updated_by	int(11)	YES			
date_updated	datetime	YES			
deleted	int(1)	NO		0	
deleted_by	int(11)	YES			
date_deleted	datetime	YES			

Query:

SELECT
e.id,
e.title,
e.eDate,
e.eDate_end,
e.eTime,
e.eTime,
e.eTime_note,
e.descr,
e.location,
e.url,
e.`file`
FROM
calendar_events e
WHERE
e.deleted =  '0' AND
e.hidden =  '0' AND
e.eDate >=  '2009-04-01' AND
e.eDate <=  '2009-04-30' AND
e.private =  '0'
ORDER BY
e.eDate ASC,
e.eTime,
e.title

 

data in eTime:

 

Link to comment
https://forums.phpfreaks.com/topic/152070-solved-time-sorting/#findComment-798608
Share on other sites

You can add a TIME type column and use the mysql STR_TO_DATE() function to produce a TIME value from your existing column data, then rename the columns and delete the old varchar column - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date

Link to comment
https://forums.phpfreaks.com/topic/152070-solved-time-sorting/#findComment-798635
Share on other sites

Archived

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

×
×
  • Create New...

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.