Calculate date difference between fixed date and current date

D

Dave Elliott

i need to calculate the number of days between my control (StartDte) and the
current date
StartDte is in this format m/d/yy with ainput mask of
99/99/00;0;_

the other unbound calculated field needs to show the number of days between
the 2 values.
other field is named (unbound) late
 
G

G. Vaught

Use the function DateDiff.
Code versionDim TheDate As Date ' Declare variables.
Dim Msg
TheDate = InputBox("Enter a date")
Msg = "Days from today: " & DateDiff("d", Now, TheDate)
MsgBox Msg

You can also type a statement within a query, such asDateDiff("d", Date(),
StartDte)The reason I use Date() is because Now returns the time also with
the date. Date just returns the date."Dave Elliott"
 
D

Dave Elliott

why wont this give the difference between text463 and startdte ?
=DateDiff("d",[Text463],"StartDte")
 
J

John Vinson

why wont this give the difference between text463 and startdte ?
=DateDiff("d",[Text463],"StartDte")

Because the eight-letter text tring "StartDte" is not a valid date.

Use [StartDte] instead to tell Access that it's a table field.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top