Re: How do I change an expression to display differently
- From: strive4peace <strive4peace2006@xxxxxxxxx>
- Date: Sun, 19 Mar 2006 03:10:24 -0500
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..
- Prev by Date: Re: =(DateDiff("yyyy",[BirthDate],Now())) Make show yrs & 10ths
- Next by Date: Selective Report Printing
- Previous by thread: Re: =(DateDiff("yyyy",[BirthDate],Now())) Make show yrs & 10ths
- Next by thread: Selective Report Printing
- Index(es):
Relevant Pages
|