Jump to content

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

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

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.

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.

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.