Solved

decimal place for MS Access byte data type

Posted on 2013-06-22
7
710 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 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 50

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

752 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