Date Query

  • Thread starter Thread starter Jalaja
  • Start date Start date
J

Jalaja

I have a field called "Date" in my Access table. I have to
get the age. That is Current date()-Date = number of
hours/days, hh:mm:ss should be the output.
I have been trying in many ways in Query. But it
says "Data mismatch" What is the solution & where can I
get information about date functions of Access ?

Thank you.
 
I have a field called "Date" in my Access table. I have to
get the age. That is Current date()-Date = number of
hours/days, hh:mm:ss should be the output.
I have been trying in many ways in Query. But it
says "Data mismatch" What is the solution & where can I
get information about date functions of Access ?

Thank you.

I'd suggest changing the field name. Date is a reserved word for the
Date() function; Access *WILL* get confused.

Take a look at the DateDiff() function in the VBA help. A Date/Time
field is stored as a Double Float number, a count of days and
fractions of a day; just subtracting will get you a decimal number of
days between the date/time entered in the field and the previous
midnight. If you want the days, hours, minutes and seconds up to the
current instant use Now() instead of Date; you will need some
expression to convert the fractional days to dd hh:nn:ss format. Air
code, untested:

ShowElapsed: DateDiff("d", [datefield], Date()) &
Format(CDate(CDbl([datefield]) - Now()), "hh:nn:ss")
 
Back
Top