Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff function

Status
Not open for further replies.

gwendon

Technical User
Apr 7, 2002
23
US
I find when I populate a text type field with a date such as "11/28/1946", I can use the following function in my Query to calculate age => DateDiff("y",[BirthDate],Date())\365.25 But the problem is when I place an input mask on my BirthDate, text type field, I get a bogus return.
I'm sure there is a simple fix beyond my knowledge?
 

when I place an input mask on my BirthDate, text type field, I get a bogus return.

I assume this is an access database. So, the data type for the BirthDate field is text? Why?

What does bogus return mean? Error message? Value?

Is BirthDate a field in the record on your form where you are trying to add the input mask or is it an unbound control?
 
Yes, this is Access 2000 database.
The bogus return is a value that is meaningless, for example => -5256
The input mask was added when the field was created in table design. I tried making the BirthDate field a time date field, but it did not seem to work. I haven't as yet created a form, I've simply been inputting the data in the table datasheet view. I wanted to work the bugs out before proceeding to create a form, based on my Query.
 
I solved the problem with the DateDiff function.
I am now using the Date Time data type field, in my equation. The simple solution is that you cannot impose an input mask on a Date Time data field because it already has its own internal mask.
So my BirthDate field is now a Date Time field without me trying to imposed an additional input mask via the properties, and the following expression works fine for returning an age: DateDiff("y",[BirthDate],Date())\365.25
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top