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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATE FIELD IN CALCULATION

Status
Not open for further replies.

maeling

Technical User
Sep 23, 2002
109
GB
I am trying to perform a calculation on my form which takes into account todays date. I would like a filed to be be text box to be calculated if todays date is the same year as the date the form is filled in. If not then I would like to return a zer0.

Example

TextboxA = 2003 text field
TextboxB = date() 25/07/2003 date field

TextboxC Iif [TextboxA]=[TextboxByear] then calculate else "0"

The calculate text represents a calculation on the form.

Hope this makes sense HELP
 
Try this example:

TextboxA = DateField - Form filled in
TextboxB = date() 25/07/2003 date field

TextboxC = IIf (Year(Format([TextboxA], "mm/dd/yyyy")= Year(Format([TextboxByear], "mm/dd/yyyy")) then calculate else "0"

The reason is convert with Format to "mm/dd/yyyy" as I have found that when the default format is dd/mm/yyyy strange results occur during comparisons.


Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
The trouble is, TextboxA isn't a date field, its just text. The user enters a year into the text field i.e 2003. I would like to extract the year from todays date text box and use that for the Iif statement. Iif like for example. In SQL their is a command that converts the date to text and then use substring to extract the year. Can something similar be done ? I couldn't get your example to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top