Solved

decimal place for MS Access byte data type

Posted on 2013-06-22
7
711 Views
Last Modified: 2013-06-23
guys, just a silly question. i want to save the amount of space for each record and i just need to store the number of hours a staff works a day. it would be like 8.75, 5.42 or soemthing like that. 2 DP essentially.

i know that memory is cheap nowadays but just for moot sake ok if yal don't mind.

in the screen shot below, it shows that for byte data type i can choose number of decimal places. i choose 2 and when i go to my table and key in 2.35 it shows up as 2.

1) is there any way i can use byte to store really small decimal places? byte takes 1 byte whereas single takes 4 bytes.
2) if i want to store decimal places the smallest data type is single right? when would you use decimal? it takes 14 bytes.

thanks guys!!

field properties for byte
0
Comment
Question by:developingprogrammer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
ID: 39268106
<<
1) is there any way i can use byte to store really small decimal places? byte takes 1 byte whereas single takes 4 bytes.
>>

 A byte can only represent whole numbers from 0 - 255 unless you scale it (multiply/divide by a factor of 10).

<<
2) if i want to store decimal places the smallest data type is single right? when would you use decimal? it takes 14 bytes.
>>

 Single is a floating point number, which if you want accurate decimal places, you don't want to use.

  Either use Currency (a scaled integer to four decimal places) or Decimal (still a scaled integer, but you can specify the scale).

Jim.
0
 
LVL 26

Assisted Solution

by:jerryb30
jerryb30 earned 100 total points
ID: 39268140
I would store time worked as a a value of 1-240, with each number 1/10th of an hour for a 24-hour day. Or, whatever granularity you want, if you presume no one would work more than n hours per day.
0
 
LVL 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 100 total points
ID: 39268272
As you are only summing the hours, Single could do, but I would use Currency.

/gustav
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 200 total points
ID: 39268655
Hi,

you maybe can set the option to 2 decimal places but as Byte is an integer value it will simply be ignored (sadly enough that Access does not hide such options in those cases, unfortunately Microsoft takes more time to insert silly features into Access than redesign some old but important editors).

You should think about the purpose and importance of any field, not only memory or data type. If you want to save the number of hours it is very important that the values will be saved very exactly because if there would be an error because of the data type the people would not be very amused..
So the minimum is to use Double as datatype, better is to use a solution like from jerryb30, because in this case you have saved the value as integer value which is 100% exact. That would only mean a little more work in the frontend where you must convert the value to a decimal format for output to the user and then back if the user enters a value (and conversion always has a little risk of losing data). So the simplest and most accurate way in my eyes would be to use currency as data type - no conversion and completely exact for the case of 2 decimal places.

By the way: You have still three fields for category in your table...;-)

Cheers,

Christian
0
 

Author Comment

by:developingprogrammer
ID: 39269220
superb!! thanks so so much guys! now i understand this a lot better! i've decided to use integer cause it uses 2 bytes only and i can definitely store all the minutes i need and secondly it's a common denominator for other types of time storage like break time minutes or lunch minutes instead of break time being 15min and hours worked being 8 hours. so now everything's in minutes. thanks guys!! = ))
0
 

Author Comment

by:developingprogrammer
ID: 39269221
and bitsqueezer thanks so much for confirming that MS Access didn't remove that really confusing decimal thing for byte data type in their field properties!! = ))
0
 
LVL 24

Expert Comment

by:Bitsqueezer
ID: 39269241
;-)
You're welcome.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question