Re: How do I change an expression to display differently

Tech-Archive recommends: Speed Up your PC by fixing your registry



uou can subtract one date from another ... as dates are storeed numerically...

if you subtract one date from another, you get the number of days with time difference as a fraction.

Access stores date/times in a numeric format where the integer portion of the number represents the date and the decimal portion of the number represents time:

1/1/100 --> -657434
1/2/100 --> -657433
12/30/1899 --> 0
1/1/1950 --> 18264
1/1/2005 --> 38353
1/1/9999 --> 2958101

the time is a fraction of the day

12 noon is 0.5
6pm is 0.75

1/1/2005, 12 noon --> 38353.5

if you have a control with just a date and you want to make sure it converts to a whole number (or it is stored in text format), use

DateValue([control_or_fieldname])

likewise, if you have a time, you can force it to the fractional part by

TimeValue([control_or_fieldname])

since dates are whole numbers and time are the fractions, theoretically, you can also do arithmetic operations on them

that is why you can subtract one date from another and get the number of days between the two

The DateDiff function can be used to specify what time increment you want returned when you subtract dates

Likewise, there is a DateAdd function to add specific time increments to a date

***

Dates, therefore, are stored as floating point numbers. This makes them inaccurate for direct comparisons anyway -- the best way to ensure you have only the the Whole part of the number (the date), is to use the Integer portion of the number (the date) only -- this, in essence, is what DateValue does. In addition to showing the result in a date format, it strips off the decimals.

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com


NewLifeAl wrote:
How can I change the following expression to display not only the years but tenths of years: =(DateDiff("yyyy",[BirthDate],Now()))? Such as 43.7 years instead of 43 or 44.
.



Relevant Pages

  • Re: Dates formula
    ... Excel dates are numbered ... So you can with caution subtract one date from another to obtain the number ... and avoid the time fraction use a function like TRUNC. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: What is the fastest way of getting the fraction part of a floating point number?
    ... What is the fastest way of getting the fraction part of a floating point ... if I have a float 10.3 what is the fastest way of getting a float ... Add 2^1, subtract 2^1, what's the difference ... ... fld D§fpu_test32 ...
    (comp.lang.asm.x86)
  • Re: Calculating sum of two given times.
    ... seems as if you want to subtract the earlier time from the later time. ... If the time will never overlap midnight, ... To show the value as a fraction, (and assuming that you will always be ... you must multiply the results of your subtraction by 24 and format the cell to ...
    (microsoft.public.excel.misc)
  • Re: Addition and subtraction of Rational Expressions
    ... >> Hey everyone, i've got a question for ya. ... >> Add or subtract ... >> do the last step I do that factors out what's on top in the fraction? ... What that example illustrates is that simplification is, ...
    (sci.math)
  • Re: Convert time to fraction of an hour
    ... Format as GENERAL or NUMBER ... Microsoft Excel MVP ... So if I subtract 12:11 from 12:34 I get ... the fraction part of the hour. ...
    (microsoft.public.excel.worksheet.functions)