Jump to content

timestamp by month/day


jester626

Recommended Posts

I have a script I am trying to write that will pull a unix timestamp from a MySQL database. I have no problem pulling the data using a WHERE starttime > ### AND endtime < ### which is good if I want to manually input a start and end time. My problem begins when i want to just pull the data out and want to simply pull the data in a GROUP By format by day. This is going to be a real simple appointment type of script. where the database has the following fields. RecID, Lastname,Firstname,AppointmentDate.

The output would be something like:

 

April 15, 2010

Appt. Time | Last Name | First Name

 

April 17, 2010

Appt. Time | Last Name | First Name

 

and so on.

 

Any help would be appreciated.

 

Jester

 

 

Link to comment
Share on other sites

You have stumbled upon yet another of the shortcomings of a Unix Timestamp. For it to be usable in the way that humans treat date/time information, it must be converted into a human date/time format.

 

You can use the mysql FROM_UNIXTIME() function to get a usable DATE or DATETIME value, but that will slow down every query that uses it. I would recommend switching to a DATE or DATETIME data type. You can do a one time conversion of your existing values into a DATE or DATETIME value.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.