Monday, October 3, 2011

To find the last day of the current month & also last day of any month and year

'To find last day of the current month
MsgBox DateSerial(Year(Now), 1 + Month(Now), 0)

'To find last day of any month and year

usr_dte = inputbox("Enter the date for which you want to know the last day of the month in the format dd/mm/yyyy")
current_date = now()
only_date = left(current_date,9)
dat_diff = datediff("m",only_date,usr_dte)
req_mnth = DateAdd ("m",dat_diff,only_date)
a = split(req_mnth,"/")
mnth = a(0)
dat = a(1)
yr= a(2)
msgbox DateSerial(yr, 1 +mnth, 0)

--Pavankumar Nandagiri

Google Search

Google