Home Privacy Policy Feedback Link to us Site Map

Access: Set up a text box to display the difference between two dates (display value of 1 if dates are the same) in Access 2003/XP/2000/97


Question:  In an Access 2003/XP/2000/97 Form or Report, I'd like to calculate/display the difference between 2 date fields (From_Date and To_Date). I want to display the number of days between 'From_Date' and 'To_Date', and if the dates are the same date, I'd like to display the result as 1.

Answer:  You can create a Text Box on your Form or Report. Then set the Control Source property of the Text Box to the following formula:

=IIf([From_Date]=[To_Date],1,DateDiff("d",[From_Date],[To_Date]))