Total Days Between Two Dates. (1 Viewer)

mshelley1

Carbo
Local time
Yesterday, 23:56
Joined
Feb 12, 2006
Messages
45
[RESOLVED] Total Days Between Two Dates.

Access 2000




Greetings:

I have a form that has three textboxes and a button. The first textbox named “Date” contains a previous date, the second textbox named ”EndDate” will contain the current date. The third textbox named “TotalDays needs to contain the total number of days between “Date” and “EndDate”. The code should run OnClick of the button named “calculate”

Thanks in advance

Resolution:

Me.TotalDays = DateDiff("d", Me.txtDate, Me.EndDate)

Thanks "boblarson"
 
Last edited:

boblarson

Smeghead
Local time
Yesterday, 21:56
Joined
Jan 12, 2001
Messages
32,059
Also, don't name objects reserved words (Date is a reserved word). It will only cause you grief. Your table fields and other objects should not have reserved words as the name nor use special characters. EndDate is fine but a text box (and/or field) named Date isn't.
 

mshelley1

Carbo
Local time
Yesterday, 23:56
Joined
Feb 12, 2006
Messages
45
This is what I have but it does not work.

TotalDays.Value = DateDiff("d", “txtDate”, "EndDate")
 

boblarson

Smeghead
Local time
Yesterday, 21:56
Joined
Jan 12, 2001
Messages
32,059
txtDate and EndDate don't have quotes around them. In fact you should qualify them and also you don't need .value after TotalDays.

Code:
Me.TotalDays = DateDiff("d", Me.txtDate, Me.EndDate)
 

Users who are viewing this thread

Top Bottom