Jump to content


Photo

DATE/TIMESTAMP Question


  • Please log in to reply
3 replies to this topic

#1 extremeguy

extremeguy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 December 2003 - 08:47 PM

I have a MySQL database table with a field that is of type TIMESTAMP(12). When I do a query, I get the result back as YYYYMMDDHHMM as expected. The syntex of my query is \"SELECT * FROM rv\". I am obviously using PHP and I am trying to take the result and split it up into 2 arrays, one for date and one for time (ie. $date == $date[0]=YYYY, $date[1]=MM, $date[2]=DD and $time == $time[0]=HH, $time[1]=mm). WHat is the easiest way to accomplish this?

I have also thought about trying to get the info from within my query, BUT I am using \"SELECT *\" and have not found a way to use \" * \" and request specific formated dates or times. I would rather stick with selecting \" * \" instead of spelling it all out in the query b/c there are 20+ fields of info that I need.

Thanks in advance for the help!

#2 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 16 December 2003 - 08:59 PM

Try something like:

SELECT *, DATE(ts) as tsdate, TIME(ts) as tstime FROM table

#3 extremeguy

extremeguy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 December 2003 - 09:05 PM

Try something like:

SELECT *, DATE(ts) as tsdate, TIME(ts) as tstime FROM table


I just tried this and it didn\'t work.

This is the SQL query that I am using: SELECT *, DATE(rv_arrive) as arrive_date, TIME(rv_arrive) as arrive_time FROM rt_rv WHERE rv_key=1001

#4 extremeguy

extremeguy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 18 December 2003 - 02:47 PM

Am I going about this all wrong? Should I be storing the values as a UNIX timestamp instead of YYYYMMDDHHMM ?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users