Forum Moderators: coopster

Message Too Old, No Replies

Ordering Data Selected from database

Date/Time issue

         

Sarah Atkinson

2:56 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



in my database I have the "when" of my events as a datetime type. I want to slect the events and print then in chronological order. However I only want to print their time (8:00 AM) I also want to seperate this into different tables (one table for each day with a table header stating the day (Monday, September 20, 2004)

How do I do this?

I thought is I select with DATE_FORMAT but do I need to do this twice? so in my select statement I have
DATE_FORMAT(when, '%W, %M, %m, %Y') as dayheader, DATE_FORMAT(when, '%l,%i,%p') as time,

and how would I get my , and : added in for formating? Would it be better to select each part speratly?

OR can I just select one and format it on the fly in my while statment?

Sarah Atkinson

4:58 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



this is what i have my query as

$result=mysql_query("SELECT id, eventname,county,where,DATE_FORMAT(when, '%I,%i,%s,%m,%d,%Y') AS date_string FROM sg_event ORDER BY 'when'");

but it isn't working but I can't figure out what the problem is?
Sarah

arran

5:10 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



You are using 'where' and 'when' as column names which are both reserved words in mysql.

Sarah Atkinson

5:18 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



lol
supose to be ewhen and ewhere

sometimes it just takes an extra set of eyes