Solved

decimal place for MS Access byte data type

Posted on 2013-06-22
7
708 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
7 Comments
 
LVL 57

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 49

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

791 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