Hi all,
I am unable to figure out the problem.How there is weeks difference coming up.
If sDOB <> "" And sScheduleDate <> "" Then
If IsDate(sDOB) And IsDate(sScheduleDate) Then
Try
sDOB = Convert.ToDateTime(sDOB)
sScheduleDate = Convert.ToDateTime(sScheduleDate)
'CALCULATE NUMBER OF YEARS
sMonths = DateDiff(DateInterval.Month, sDOB, sScheduleDate)
'Calculate the Months
'sMonths = (DateDiff("m", sDOB, sScheduleDate))
If (DatePart("d", sDOB) > DatePart("d", sScheduleDate)) Then
sMonths = sMonths - 1
End If
If sMonths < 0 Then
sMonths = sMonths + 1
End If
sYears = Math.Floor(sMonths / 12)
sMonths = CInt(sMonths Mod 12)
Return CStr(sYears) & " years " & CStr(sMonths) & " Months"
End Function
Thanks for any help in advance.
I am unable to figure out the problem.How there is weeks difference coming up.
If sDOB <> "" And sScheduleDate <> "" Then
If IsDate(sDOB) And IsDate(sScheduleDate) Then
Try
sDOB = Convert.ToDateTime(sDOB)
sScheduleDate = Convert.ToDateTime(sScheduleDate)
'CALCULATE NUMBER OF YEARS
sMonths = DateDiff(DateInterval.Month, sDOB, sScheduleDate)
'Calculate the Months
'sMonths = (DateDiff("m", sDOB, sScheduleDate))
If (DatePart("d", sDOB) > DatePart("d", sScheduleDate)) Then
sMonths = sMonths - 1
End If
If sMonths < 0 Then
sMonths = sMonths + 1
End If
sYears = Math.Floor(sMonths / 12)
sMonths = CInt(sMonths Mod 12)
Return CStr(sYears) & " years " & CStr(sMonths) & " Months"
End Function
Thanks for any help in advance.