natatkinson Posted July 9, 2008 Share Posted July 9, 2008 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 00:00:08.10 it stores 00:00:08.1 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 https://forums.phpfreaks.com/topic/113908-formating-of-time-data/ Share on other sites More sharing options...
natatkinson Posted July 9, 2008 Author Share Posted July 9, 2008 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 https://forums.phpfreaks.com/topic/113908-formating-of-time-data/#findComment-585408 Share on other sites More sharing options...
btherl Posted July 9, 2008 Share Posted July 9, 2008 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 https://forums.phpfreaks.com/topic/113908-formating-of-time-data/#findComment-585917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.