Solved

decimal place for MS Access byte data type

Posted on 2013-06-22
7
705 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now