[+] public STRING LastDateOfTheMonth()
[ ] // ==========================================================
[+] // FUNCTION: LastDateOfTheMonth()
[ ] //
[ ] // DESCRIPTION:
[ ] // This function will return the last date of the current month
[ ] // ==========================================================
[+] // Variable declarations
[ ] INTEGER iDay,iMonth,iYear
[ ] DATETIME dtDateTime
[ ] STRING sDate,sMonth,sYear
[ ]
[+] do
[ ] sMonth = FormatDateTime(GetDateTime(), "m")
[ ] iMonth = Val(sMonth)
[ ] sYear= FormatDateTime(GetDateTime(), "yyyy")
[ ] iYear = Val(sYear)
[ ]
[+] switch (iMonth)
[-] case 2
[ ] // if year is divisible by 4 and not divisible by 100
[-] if ((iYear % 4 == 0) && (iYear % 100) > 0)
[ ] iDay = 29
[ ] //or if year is divisible by 400
[-] else if (iYear % 400 == 0)
[ ] iDay= 29
[-] else
[ ] iDay= 28
[-] case 4
[ ] iDay= 30
[-] case 6
[ ] iDay= 30
[-] case 9
[ ] iDay= 30
[-] case 11
[ ] iDay= 30
[-] default
[ ] iDay= 31
[ ]
[ ] dtDateTime=MakeDateTime(iYear, iMonth, iDay)
[ ] sDate=FormatDateTime(dtDateTime,"m/d/yyyy")
[+] except
[ ] ExceptLog()
[ ]
[ ] return sDate
[ ] // ==========================================================
[+] // FUNCTION: LastDateOfTheMonth()
[ ] //
[ ] // DESCRIPTION:
[ ] // This function will return the last date of the current month
[ ] // ==========================================================
[+] // Variable declarations
[ ] INTEGER iDay,iMonth,iYear
[ ] DATETIME dtDateTime
[ ] STRING sDate,sMonth,sYear
[ ]
[+] do
[ ] sMonth = FormatDateTime(GetDateTime(), "m")
[ ] iMonth = Val(sMonth)
[ ] sYear= FormatDateTime(GetDateTime(), "yyyy")
[ ] iYear = Val(sYear)
[ ]
[+] switch (iMonth)
[-] case 2
[ ] // if year is divisible by 4 and not divisible by 100
[-] if ((iYear % 4 == 0) && (iYear % 100) > 0)
[ ] iDay = 29
[ ] //or if year is divisible by 400
[-] else if (iYear % 400 == 0)
[ ] iDay= 29
[-] else
[ ] iDay= 28
[-] case 4
[ ] iDay= 30
[-] case 6
[ ] iDay= 30
[-] case 9
[ ] iDay= 30
[-] case 11
[ ] iDay= 30
[-] default
[ ] iDay= 31
[ ]
[ ] dtDateTime=MakeDateTime(iYear, iMonth, iDay)
[ ] sDate=FormatDateTime(dtDateTime,"m/d/yyyy")
[+] except
[ ] ExceptLog()
[ ]
[ ] return sDate
No comments:
Post a Comment