DateTime

  • Thread starter Thread starter ChrisC
  • Start date Start date
C

ChrisC

Since I have never had the need to do this nor can I seam
to figure it out, can anyone tell me how I can take 2
Dates and return how many months there are left till I
reach a third date?

Example:

Release date = "2/1/2001"

Expire date = "2/1/2006"

Current date "12/10/2003"

I need to know the differenc between the "current date"
and the "expire date" in months.

Anyone?

Thanks.
 
ChrisC said:
Since I have never had the need to do this nor can I seam
to figure it out, can anyone tell me how I can take 2
Dates and return how many months there are left till I
reach a third date?

Example:

Release date = "2/1/2001"

Expire date = "2/1/2006"

Current date "12/10/2003"

I need to know the differenc between the "current date"
and the "expire date" in months.

Anyone?

Get the current date and the expire date as DateTime, then subtract one
from the other to get a TimeSpan - use that to work out the number of
months between the two, depending on *exactly* what you mean by "in
months" - there are any number of different ways of interpreting that,
unfortunately.
 
ChrisC said:
Release date = "2/1/2001"

Expire date = "2/1/2006"

Current date "12/10/2003"

I need to know the differenc between the "current date"
and the "expire date" in months.

Use the DateInterval.???? (the ???? has several options... hour, day, month,
etc... your choice). My example uses 'day'.

Dim dtChk1, dtChk2 As Date
dtChk1 = FormatDateTime(gblWeeksEndDate, DateFormat.LongDate)
dtChk2 = FormatDateTime(WeekEndDate, DateFormat.LongDate)
gblDtChk = DateDiff(DateInterval.Day, dtChk1, dtChk2)
 
Back
Top