I have a webtable. Webtable contains 12 columns (Jan, Feb, Mar, April, May….Etc) and 1 Row (No. Of Days). Every day Change the Numbers in the Row. (Means Ex: Aug Month Column Total Number of days in Aug is 31 Days. Today date is 21st. In Aug Month Column specify No.Of days Cell is 11 (days). (08/31/2006 – 08/21/2006).
Is their any Method to calculate the remaining days.
Re: How can I calculate the Days. (Particular Month)
30 days has September, April, June and November.
All the rest have 31, except February which as 28 if it's not a leap year, or 29 if it is a leap year.
<font class="small">Code:</font><hr /><pre>function isLeapYear(ByVal TheYear)
isLeapYear = CBool(Year(TheYear) Mod 4)
end function
function getDaysInMonth(ByVal TheMonth, ByVal TheYear)
If (TheMonth = "09") OR (TheMonth = "04") OR (TheMonth = "06") OR (TheMonth = "11") Then
getDaysInMonth = 30
ElseIf (TheMonth = "02") Then
If isLeapYear(TheYear) Then
getDaysInMonth = 29
Else
getDaysInMonth = 28
End If
Else
getDaysInMonth = 31
End If
end function
Re: How can I calculate the Days. (Particular Month)
Hi Sai,
Here wt you are testing? Your description is somewhat confusing. Anyway what i understand is it is current date is 21st Aug, 11days will be displayed in the No.of days cell and if it is 22nd Aug, 10 days will displayed in the No.of days cell. My understanding is clear , then its very simple to very the data in No.of days cell.
User For Loop wihtin that on use Select statement up to 12 cases like Jan to Dec. capture the current date and Month and calculate the days as we are giving the Total no.of days for each month in the for each case.
write all above code in VB script only.
Thats all. If not working this solution with you let me know. I will send the code.
Re: How can I calculate the Days. (Particular Month)
Hi Kiran,
Thanks, This is my Description.It is current date is 21st Aug, 11days will be displayed in the No.of days cell and if it is 22nd Aug, 10 days will displayed in the No.of days cell. How can i write the code.
Please help me.
If intMonth=2 Then
If isLeapYear(intYear) Then
fnGetDate = DateDiff("d", strDate, CDate(intMonth & " 29" & ", " & intYear))
Else
fnGetDate = DateDiff("d", strDate, CDate(intMonth & " 28" & ", " & intYear))
End If
elseif intMonth=4 or intMonth=6 or intMonth=9 or intMonth=11 then
fnGetDate = DateDiff("d", strDate, CDate(intMonth & " 30" & ", " & intYear))
else
fnGetDate = DateDiff("d", strDate, CDate(intMonth & " 31" & ", " & intYear))
End If
End Function
function isLeapYear(ByVal TheYear)
isLeapYear = CBool(Year(TheYear) Mod 4)
end function
Re: How can I calculate the Days. (Particular Month)
Thanks It's Working Fine.
And I have a question How can i insert This code to Particular webtable cell. Because My webtable cell value is change very day. When i insert the checkpoint It's working fine today only. Tommorrow It's Fail (Cell Value Change).
Re: How can I calculate the Days. (Particular Mont
You can populate the data table with the calculated values - remaining days for all the months based on the current day passed as a parameter to the function.
After that you can define a table checkpoint on the webtable which uses parameter - which picks the corresponding value from the data table for the corresponding month to check against.