|
-
Jan 7th, 2005, 01:01 AM
#1
Thread Starter
Lively Member
Calculate Date
Hello Friends
I need to find out the difference between two dates
the one i know is datediff but it gives me either No of days or year
i want it to be in this fashion
days/Months/Year
in date format
-
Jan 7th, 2005, 01:25 AM
#2
Re: Calculate Date
VB Code:
Dim IYourAgeInDays As Long
'First you need to see if a valid date is entered.
If IsDate(Text1.Text) Then
whatevervariable = CDate(Text1.Text)
'then use DateDiff
lYourAgeInDays = DateDiff("d", whatevervariable, Now) 'd = days
lblAgeDays.Caption = CStr(lYourAgeInDays) 'put on label
s = seconds
yyyy = years
m = months
Else
MsgBox "Error"
End If
Hope it helps!
VB.NET MVP 2008 - Present
-
Jan 7th, 2005, 01:47 AM
#3
Thread Starter
Lively Member
Re: Calculate Date
It has given me the number of days but then to calculate it to years Month days was the Question
-
Jan 7th, 2005, 01:59 AM
#4
Re: Calculate Date
 Originally Posted by vbcoder2
It has given me the number of days but then to calculate it to years Month days was the Question
Instead of: DateDiff("d", whatevervariable, Now) 'd = days
Use DateDiff("m", whatevervariable2, Now) 'm = Months
and DateDiff("yyyy", whatevervariable3, Now) 'yyyy = years
VB.NET MVP 2008 - Present
-
Jan 7th, 2005, 02:33 AM
#5
Registered User
Re: Calculate Date
Hello
This should also get the answer in the format of dd/mm/yy. Hope its what ur after.
VB Code:
Text1.Text = Format(DateDiff("d", "1/2/02", "1/2/03", vbSunday, vbFirstJan1), "dd/mm/yy", vbSunday, vbFirstJan1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|