this code will show you on how to calculate the difference of two dates like for example 1
0/10/2010 to 10/01/2010 to find the lapsed day we use a Date Diff function that is
built in VB6 so the code will look like this:
0/10/2010 to 10/01/2010 to find the lapsed day we use a Date Diff function that is
built in VB6 so the code will look like this:
Label1.Caption = DateDiff("d", #10/1/2010#, #10/10/2010#)
at this code i display the output on a label control did you notice that the Date Diff function i
s there,since i am looking for day lapsed to 10/01/2010 to 10/10/2010 the output is 9 if you
s there,since i am looking for day lapsed to 10/01/2010 to 10/10/2010 the output is 9 if you
are looking for a month just simply change the letter "d" to letter "m" for a month symbol
and of course it is not complete if i did not include for a year,so for the year calculation just
simply change also the letter on a two double quote(" ") to a "yyyy" and you got the answer......
and of course it is not complete if i did not include for a year,so for the year calculation just
simply change also the letter on a two double quote(" ") to a "yyyy" and you got the answer......
for a Month:
DateDiff("m", #10/1/2010#, #10/10/2010#)
for a Year:
DateDiff("yyyy", #10/1/2010#, #10/10/2010#)
done like this:
this will add 3 days on your current system date
DateAdd("d", 3, Now)
this will add 3 months on your current system date
for a Month:
DateAdd("m", 3, Now)
this will add 3 years on your current system date for a Year:
DateAdd("yyyy", 3, Now)
Hope this will help to you!!
Happy Coding
Tags:
VB6 Functions,
Visual Basic 6.0
Leave a comment