Jump to content

Formating of Time data


Recommended Posts

I have been working since February on a CMS for a Track & Field team, and teh whole system is coming along nicely.


For the storage of track results (times) I chose time without timestamp because it allowed decimal storage (this was actually the reason I chose PostgreSQL over MySQL).  But the only problem is PostgreSQL does not store trailing zeroes IF THEY ARE ENTERED.  Meaning, if you enter



it stores




Track uses 2 decimal points to notate that the time was recorded using a Fully Automated Computer Timing system, and older hand times are only notated using 1 or 0 decimal places.  So how the time is displayed is actually important.


I've been messing around with a way to get the data to store correctly, but I don't think I can change that, so now I am trying to get the data to display correctly on the php pages, and I'm having alot of trouble.  My last attempt I added a column to the results table called 'precision', so each result would specify if it had 0, 1, or 2 decimal points of precision.  I was then going to use some sort of php number format to get this to work, but I got nowhere.


If anyone can help me, I would GREATLY appreciate it.  It is only a little issue, but it would really make my web application top notch.


For more info, test website is here: http://www.eiublue.com


and some of my documentation is here: http://pen.eiu.edu/~nratkinson2/db/EIUrunning%20CMS/

Link to comment
Share on other sites

Okay, I have come up with solution that I think shoudl work.


When the data is input, I do a sscanf to find if the data is input with .0 or .00.


If it is, I store the decimal precisions in a variable, and add it to a column in the database.  Its a workaround, sad to say I have to do one, but as long as it works, i guess i'm happy.

Link to comment
Share on other sites

I think that adding a precision column is the way to go.  A "numeric" type like timestamp simply cannot distinguish trailing zeros, because the values are numerically equivalent.  Like a floating point number 1.0 cannot be distinguished from 1.00, unless you store the precision separately.

Link to comment
Share on other sites


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.