I face that problems
07/01/2003 06/30/2006 > it should be 3
01/01/2003 02/28/2005 >could i get 2 years and 2 months
01/01/2003 03/01/2005 >could i get 2 years and 2 months and 1
day 8 5908
inamori wrote: I face that problems
07/01/2003 06/30/2006 > it should be 3 01/01/2003 02/28/2005 >could i get 2 years and 2 months
01/01/2003 03/01/2005 >could i get 2 years and 2 months and 1 day
Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is:
3 years, 11 months, and 29 days
The difference between 1/1/2003 and 2/28/2005 is:
2 years, 1 months, and 27 days
The difference between 1/1/2003 and 3/1/2005 is:
2 years, 2 months, and 0 days
What is the logic used to determine when to add one day to the results?
Should the difference between 07/01/2003 and 07/01/2003 be 1 day? How about
07/01 and 07/02?
This is the code I used to get the above results:
<%
dim arDates(2,1), iYrs, iMths, iDays, i
arDates(0,0) = #20030701#
arDates(0,1) = #20060630#
arDates(1,0) = #20030101#
arDates(1,1) = #20050228#
arDates(2,0) = #20030101#
arDates(2,1) = #20050301#
for i = 0 to 2
Response.Write "The difference between " & arDates(i,0) & _
" and " & arDates(i,1) & " is: "
iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1))
Response.Write iYrs & " years, "
iMths=DateDiff("m",arDates(i,0),arDates(i,1))
if iMths < 12*iYrs then iYrs = iYrs  1
if iMths  12*iYrs < 0 then
Response.Write " 0 months, and "
else
Response.Write iMths  12*iYrs & " months, and "
end if
iDays = DateDiff("d",arDates(i,0), _
DateAdd("m", 1*iMths, arDates(i,1)))
if iDays < 1 then iDays = 0
Response.Write iDays & " days"
Response.Write "<BR>"
next
%>
Bob Barrows

Microsoft MVP  ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply offline, then remove the
"NO SPAM"
Bob Barrows [MVP] wrote on 21 aug 2004 in
microsoft.public.inetserver.asp.general: Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is: 3 years, 11 months, and 29 days
Hi, Bob,
2000 years ago, people where used to including the first and last day in a
declaration of time passed.
It was like a 100 meter long barbed wire fence, with one pole per meter
consisting of 101 poles.
Likewise a duration of 7 weeks, 49 days in modern count, was called 50
days, pentecost [whitsun, 49 days after easter] being the Greek word
pentakosta for 50.
I suppose the OQ could be of ancient stock.

Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Thanks for yoiur programming
add one day because of business logic
Lease agreement
01/01/2003 12/31/2006 3 years
01/01/2003 01/01/2007 3 years + 1 day
That why i need add one day on the end date....
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... inamori wrote: I face that problems
07/01/2003 06/30/2006 > it should be 3 01/01/2003 02/28/2005 >could i get 2 years and 2 months
01/01/2003 03/01/2005 >could i get 2 years and 2 months and 1 day Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is: 3 years, 11 months, and 29 days The difference between 1/1/2003 and 2/28/2005 is: 2 years, 1 months, and 27 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days
What is the logic used to determine when to add one day to the results? Should the difference between 07/01/2003 and 07/01/2003 be 1 day? How
about 07/01 and 07/02?
This is the code I used to get the above results: <% dim arDates(2,1), iYrs, iMths, iDays, i arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 Response.Write "The difference between " & arDates(i,0) & _ " and " & arDates(i,1) & " is: " iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1)) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),arDates(i,1)) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, arDates(i,1))) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
Bob Barrows  Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"
Change the code to this:
<%
dim arDates(2,1), iYrs, iMths, iDays, i, dDate
arDates(0,0) = #20030701#
arDates(0,1) = #20060630#
arDates(1,0) = #20030101#
arDates(1,1) = #20050228#
arDates(2,0) = #20030101#
arDates(2,1) = #20050301#
for i = 0 to 2
dDate = DateAdd("d",1,arDates(i,1))
Response.Write "The difference between " & arDates(i,0) & _
" and " & dDate & " is: "
iYrs=DateDiff("yyyy",arDates(i,0),dDate)
Response.Write iYrs & " years, "
iMths=DateDiff("m",arDates(i,0),dDate)
if iMths < 12*iYrs then iYrs = iYrs  1
if iMths  12*iYrs < 0 then
Response.Write " 0 months, and "
else
Response.Write iMths  12*iYrs & " months, and "
end if
iDays = DateDiff("d",arDates(i,0), _
DateAdd("m", 1*iMths, dDate))
if iDays < 1 then iDays = 0
Response.Write iDays & " days"
Response.Write "<BR>"
next
%>
inamori wrote: Thanks for yoiur programming
add one day because of business logic
Lease agreement
01/01/2003 12/31/2006 3 years
01/01/2003 01/01/2007 3 years + 1 day
That why i need add one day on the end date....
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... inamori wrote: I face that problems
07/01/2003 06/30/2006 > it should be 3 01/01/2003 02/28/2005 >could i get 2 years and 2 months
01/01/2003 03/01/2005 >could i get 2 years and 2 months and 1 day
Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is: 3 years, 11 months, and 29 days The difference between 1/1/2003 and 2/28/2005 is: 2 years, 1 months, and 27 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days
What is the logic used to determine when to add one day to the results? Should the difference between 07/01/2003 and 07/01/2003 be 1 day? How about 07/01 and 07/02?
This is the code I used to get the above results: <% dim arDates(2,1), iYrs, iMths, iDays, i arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 Response.Write "The difference between " & arDates(i,0) & _ " and " & arDates(i,1) & " is: " iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1)) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),arDates(i,1)) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, arDates(i,1))) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
Bob Barrows  Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"

Microsoft MVP  ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply offline, then remove the
"NO SPAM"
Yes. That is what I said in my revious response isn't it?
Just in case you missed it, here it is again:
************************************************** **************
Change the code to this:
<%
dim arDates(2,1), iYrs, iMths, iDays, i, dDate
arDates(0,0) = #20030701#
arDates(0,1) = #20060630#
arDates(1,0) = #20030101#
arDates(1,1) = #20050228#
arDates(2,0) = #20030101#
arDates(2,1) = #20050301#
for i = 0 to 2
dDate = DateAdd("d",1,arDates(i,1))
Response.Write "The difference between " & arDates(i,0) & _
" and " & dDate & " is: "
iYrs=DateDiff("yyyy",arDates(i,0),dDate)
Response.Write iYrs & " years, "
iMths=DateDiff("m",arDates(i,0),dDate)
if iMths < 12*iYrs then iYrs = iYrs  1
if iMths  12*iYrs < 0 then
Response.Write " 0 months, and "
else
Response.Write iMths  12*iYrs & " months, and "
end if
iDays = DateDiff("d",arDates(i,0), _
DateAdd("m", 1*iMths, dDate))
if iDays < 1 then iDays = 0
Response.Write iDays & " days"
Response.Write "<BR>"
next
%>
************************************************** *********
inamori wrote: so could I add one date of the end date in your program
so i can get what i want???
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... inamori wrote: I face that problems
07/01/2003 06/30/2006 > it should be 3 01/01/2003 02/28/2005 >could i get 2 years and 2 months
01/01/2003 03/01/2005 >could i get 2 years and 2 months and 1 day
Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is: 3 years, 11 months, and 29 days The difference between 1/1/2003 and 2/28/2005 is: 2 years, 1 months, and 27 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days
What is the logic used to determine when to add one day to the results? Should the difference between 07/01/2003 and 07/01/2003 be 1 day? How about 07/01 and 07/02?
This is the code I used to get the above results: <% dim arDates(2,1), iYrs, iMths, iDays, i arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 Response.Write "The difference between " & arDates(i,0) & _ " and " & arDates(i,1) & " is: " iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1)) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),arDates(i,1)) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, arDates(i,1))) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
Bob Barrows  Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"

Microsoft MVP  ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply offline, then remove the
"NO SPAM"
HI, I have tried your program
The output is something like that
The difference between 7/1/2003 and 7/1/2006 is: 3 years, 0 months, and 0
days
The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0
days
The difference between 1/1/2003 and 3/2/2005 is: 2 years, 2 months, and 1
days
But actually what i want is
The difference between 7/1/2003 and 7/1/2006 is: 3 years, 0 months, and 1
days
The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 1
days
The difference between 1/1/2003 and 3/2/2005 is: 2 years, 2 months, and 2
days
can it be done? is it really logic error in computer mechanism
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OJ*************@TK2MSFTNGP12.phx.gbl... Yes. That is what I said in my revious response isn't it? Just in case you missed it, here it is again: ************************************************** ************** Change the code to this:
<% dim arDates(2,1), iYrs, iMths, iDays, i, dDate arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 dDate = DateAdd("d",1,arDates(i,1)) Response.Write "The difference between " & arDates(i,0) & _ " and " & dDate & " is: " iYrs=DateDiff("yyyy",arDates(i,0),dDate) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),dDate) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, dDate)) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
************************************************** *********
inamori wrote: so could I add one date of the end date in your program
so i can get what i want???
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... inamori wrote: I face that problems
07/01/2003 06/30/2006 > it should be 3 01/01/2003 02/28/2005 >could i get 2 years and 2 months
01/01/2003 03/01/2005 >could i get 2 years and 2 months and 1 day
Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is: 3 years, 11 months, and 29 days The difference between 1/1/2003 and 2/28/2005 is: 2 years, 1 months, and 27 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days
What is the logic used to determine when to add one day to the results? Should the difference between 07/01/2003 and 07/01/2003 be 1 day? How about 07/01 and 07/02?
This is the code I used to get the above results: <% dim arDates(2,1), iYrs, iMths, iDays, i arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 Response.Write "The difference between " & arDates(i,0) & _ " and " & arDates(i,1) & " is: " iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1)) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),arDates(i,1)) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, arDates(i,1))) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
Bob Barrows  Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"
 Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"
I goofed. The code should be:
<%
dim arDates(2,1), iYrs, iMths, iDays, i, dDate
arDates(0,0) = #20030701#
arDates(0,1) = #20060630#
arDates(1,0) = #20030101#
arDates(1,1) = #20050228#
arDates(2,0) = #20030101#
arDates(2,1) = #20050301#
for i = 0 to 2
dDate = DateAdd("d",1,arDates(i,1))
Response.Write "The difference between " & arDates(i,0) & _
" and " & arDates(i,1) & " is: "
iYrs=DateDiff("yyyy",arDates(i,0),dDate)
Response.Write iYrs & " years, "
iMths=DateDiff("m",arDates(i,0),dDate)
if iMths < 12*iYrs then iYrs = iYrs  1
if iMths  12*iYrs < 0 then
Response.Write " 0 months, and "
else
Response.Write iMths  12*iYrs & " months, and "
end if
iDays = DateDiff("d",arDates(i,0), _
DateAdd("m", 1*iMths, dDate))
if iDays < 1 then iDays = 0
Response.Write iDays & " days"
Response.Write "<BR>"
next
%>
Inamori Izumi wrote: HI, I have tried your program
The output is something like that The difference between 7/1/2003 and 7/1/2006 is: 3 years, 0 months, and 0 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days The difference between 1/1/2003 and 3/2/2005 is: 2 years, 2 months, and 1 days
But actually what i want is
The difference between 7/1/2003 and 7/1/2006 is: 3 years, 0 months, and 1 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 1 days The difference between 1/1/2003 and 3/2/2005 is: 2 years, 2 months, and 2 days
can it be done? is it really logic error in computer mechanism "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:OJ*************@TK2MSFTNGP12.phx.gbl... Yes. That is what I said in my revious response isn't it? Just in case you missed it, here it is again: ************************************************** ************** Change the code to this:
<% dim arDates(2,1), iYrs, iMths, iDays, i, dDate arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 dDate = DateAdd("d",1,arDates(i,1)) Response.Write "The difference between " & arDates(i,0) & _ " and " & dDate & " is: " iYrs=DateDiff("yyyy",arDates(i,0),dDate) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),dDate) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, dDate)) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
************************************************** *********
inamori wrote: so could I add one date of the end date in your program
so i can get what i want???
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... inamori wrote: > I face that problems > > 07/01/2003 06/30/2006 > it should be 3 > > > > 01/01/2003 02/28/2005 >could i get 2 years and 2 > months > > > 01/01/2003 03/01/2005 >could i get 2 years and 2 > months and 1 day
Could you explain why these aren't the correct results?
The difference between 7/1/2003 and 6/30/2006 is: 3 years, 11 months, and 29 days The difference between 1/1/2003 and 2/28/2005 is: 2 years, 1 months, and 27 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days
What is the logic used to determine when to add one day to the results? Should the difference between 07/01/2003 and 07/01/2003 be 1 day? How about 07/01 and 07/02?
This is the code I used to get the above results: <% dim arDates(2,1), iYrs, iMths, iDays, i arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 Response.Write "The difference between " & arDates(i,0) & _ " and " & arDates(i,1) & " is: " iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1)) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),arDates(i,1)) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, arDates(i,1))) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
Bob Barrows  Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"
 Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"

Microsoft MVP  ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply offline, then remove the
"NO SPAM"
thanks
let me test tomorrow when I work
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó
news:ON*************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g... I goofed. The code should be:
<% dim arDates(2,1), iYrs, iMths, iDays, i, dDate arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 dDate = DateAdd("d",1,arDates(i,1)) Response.Write "The difference between " & arDates(i,0) & _ " and " & arDates(i,1) & " is: " iYrs=DateDiff("yyyy",arDates(i,0),dDate) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),dDate) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, dDate)) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %> Inamori Izumi wrote: HI, I have tried your program
The output is something like that The difference between 7/1/2003 and 7/1/2006 is: 3 years, 0 months, and 0 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 0 days The difference between 1/1/2003 and 3/2/2005 is: 2 years, 2 months, and 1 days
But actually what i want is
The difference between 7/1/2003 and 7/1/2006 is: 3 years, 0 months, and 1 days The difference between 1/1/2003 and 3/1/2005 is: 2 years, 2 months, and 1 days The difference between 1/1/2003 and 3/2/2005 is: 2 years, 2 months, and 2 days
can it be done? is it really logic error in computer mechanism "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:OJ*************@TK2MSFTNGP12.phx.gbl... Yes. That is what I said in my revious response isn't it? Just in case you missed it, here it is again: ************************************************** ************** Change the code to this:
<% dim arDates(2,1), iYrs, iMths, iDays, i, dDate arDates(0,0) = #20030701# arDates(0,1) = #20060630# arDates(1,0) = #20030101# arDates(1,1) = #20050228# arDates(2,0) = #20030101# arDates(2,1) = #20050301#
for i = 0 to 2 dDate = DateAdd("d",1,arDates(i,1)) Response.Write "The difference between " & arDates(i,0) & _ " and " & dDate & " is: " iYrs=DateDiff("yyyy",arDates(i,0),dDate) Response.Write iYrs & " years, " iMths=DateDiff("m",arDates(i,0),dDate) if iMths < 12*iYrs then iYrs = iYrs  1 if iMths  12*iYrs < 0 then Response.Write " 0 months, and " else Response.Write iMths  12*iYrs & " months, and " end if iDays = DateDiff("d",arDates(i,0), _ DateAdd("m", 1*iMths, dDate)) if iDays < 1 then iDays = 0 Response.Write iDays & " days" Response.Write "<BR>" next %>
************************************************** *********
inamori wrote: so could I add one date of the end date in your program
so i can get what i want???
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ¦b¶l¥ó news:%2****************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... > inamori wrote: >> I face that problems >> >> 07/01/2003 06/30/2006 > it should be 3 >> >> >> >> 01/01/2003 02/28/2005 >could i get 2 years and 2 >> months >> >> >> 01/01/2003 03/01/2005 >could i get 2 years and 2 >> months and 1 day > > Could you explain why these aren't the correct results? > > The difference between 7/1/2003 and 6/30/2006 is: > 3 years, 11 months, and 29 days > The difference between 1/1/2003 and 2/28/2005 is: > 2 years, 1 months, and 27 days > The difference between 1/1/2003 and 3/1/2005 is: > 2 years, 2 months, and 0 days > > What is the logic used to determine when to add one day to the > results? Should the difference between 07/01/2003 and 07/01/2003 be > 1 day? How about 07/01 and 07/02? > > This is the code I used to get the above results: > <% > dim arDates(2,1), iYrs, iMths, iDays, i > arDates(0,0) = #20030701# > arDates(0,1) = #20060630# > arDates(1,0) = #20030101# > arDates(1,1) = #20050228# > arDates(2,0) = #20030101# > arDates(2,1) = #20050301# > > for i = 0 to 2 > Response.Write "The difference between " & arDates(i,0) & _ > " and " & arDates(i,1) & " is: " > iYrs=DateDiff("yyyy",arDates(i,0),arDates(i,1)) > Response.Write iYrs & " years, " > iMths=DateDiff("m",arDates(i,0),arDates(i,1)) > if iMths < 12*iYrs then iYrs = iYrs  1 > if iMths  12*iYrs < 0 then > Response.Write " 0 months, and " > else > Response.Write iMths  12*iYrs & " months, and " > end if > iDays = DateDiff("d",arDates(i,0), _ > DateAdd("m", 1*iMths, arDates(i,1))) > if iDays < 1 then iDays = 0 > Response.Write iDays & " days" > Response.Write "<BR>" > next > %> > > Bob Barrows >  > Microsoft MVP  ASP/ASP.NET > Please reply to the newsgroup. This email account is my spam trap > so I don't check it very often. If you must reply offline, then > remove the "NO SPAM"
 Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"
 Microsoft MVP  ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply offline, then remove the "NO SPAM"
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CJM 
last post by:
I have an ASP page that lists files and folders in a directory. I'm using a
cookie to record the last time this page was visited, and I intend to show
links that are created/modified from that date...

by: Lofty 
last post by:
Hi all.
I have to write an app that interacts with mySQL (I really must have done
some evil, evil stuff in a previous life to be landed with this!)
I need to work out the difference in days...

by: intl04 
last post by:
I'm trying to set up a query that will include a new field ('Days
until completion') whose value is derived from the DateDiff function.
I think I have the syntax correct but am not sure.
Days...

by: Paolo 
last post by:
I am having some problem with a Year Function.
I have form on which I have 4 field which indicate dates and an
additional form which sums those dates:
These are the fields:
YEARS...

by: PMBragg 
last post by:
ORINGINAL Post
>Thank you in advance. I'm trying to pull all inventory items from December
>of the previous year back to 4 years for my accountant. I know this can be
>done, but I'm drawing a...

by: Adrian 
last post by:
I hit on this problem converting a VB.NET insurance application to C#.
Age next birthday calculated from date of birth is often needed in
insurance premium calculations.
Originally done using...

by: sr 
last post by:
Anyone know of a better way to simulate a datediff for C#, i.e.,
without referencing the VB.NET runtime?
Only added the functionality that was needed for me so it is not
the full implementation...

by: kevinjwilson 
last post by:
I am trying to get the date difference between two dates but I don't
want the function to include weekends in the calculation. Does anyone
have an idea on how to make this work?

by: muddasirmunir 
last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff
i had try it withh many syntax but getting error...

by: isladogs 
last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
For other local times, please check World Time Buddy
In...

by: abbasky 
last post by:
### Vandf component communication method one: data sharing
Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...

by: stefan129 
last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multidomain SSL certificates? Any recommendations on reliable providers or specific...

by: egorbl4 
last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это
Что это? Что мне с этим делать?
...

by: davi5007 
last post by:
Hi,
Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

by: MeoLessi9 
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

by: DolphinDB 
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...

by: Aftab Ahmad 
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

by: Aftab Ahmad 
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
 