Date math Question.

  • Thread starter Thread starter pmclinn
  • Start date Start date
P

pmclinn

If you have date a = 12/11/2004
and you want to see how many days it has been to NOW()
What is the most efficient way to perform this equation?

-Peter
 
Hi

d1 = Now.Date
d2 = Date.Parse(txtDate.Text)
MsgBox("The difference is: " & DateDiff(DateInterval.Day, d1, d2) & " days")

but for the result you want you have to change d1 and d2 so:

MsgBox(DateDiff(DateInterval.Day, d2, d1) & " days have passed")

hth
greetz Peter
 
pmclinn said:
If you have date a = 12/11/2004
and you want to see how many days it has been to NOW()

\\\
Dim d1 As Date = #10/10/1999#
Dim d2 As Date = Date.Now
MsgBox(d2.Subtract(d1).Days.ToString())
///
 

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

Similar Threads


Back
Top