CoderZone.org

Category: >> ASP/VB Code >> Get last and next months with ASP Bookmark and Share

<< lastnext >>

Snippet Name: Get last and next months with ASP

Description: Handy function gets you the last or previous month and the next month. Useful for calendars, date calculations, etc.

Also see:
» Date Picker Form in ASP
» Sort A File List By Month Name In ...
» Date: Find first day of the month
» Date Functions: MONTHS_BETWEEN
» Date Functions: ADD_MONTHS
» Create monthly partitions
» Month, Day, Year dropdown boxes
» Quick calendar example
» Calendar for any month any year
» Basic PHP Calendar
» Months_Between function
» Date Functions: Add Months
» Avoid overlapping months and years
» Days in month #2
» Days in month #1

Comment: (none)

Author:
Language: ASP
Highlight Mode: ASP
Last Modified: December 04th, 2010

<%
 
Function GetLastMonth(iCurrentMonth,iCurrentYear)
 GetLastMonth=month(dateserial(iCurrentYear,iCurrentMonth,1)-1)
End Function
 
Function GetLastMonthYear(iCurrentMonth,iCurrentYear)
 GetLastMonthYear=Year(dateserial(iCurrentYear,iCurrentMonth,1)-1)
End Function
 
Function GetNextMonth(iCurrentMonth,iCurrentYear)
 GetNextMonth=month(dateserial(iCurrentYear,iCurrentMonth+1,1))
End Function
 
Function GetNextMonthYear(iCurrentMonth,iCurrentYear)
 GetNextMonthYear=year(dateserial(iCurrentYear,iCurrentMonth+1,1))
End Function
%>
 
<%
'Example Usage:
response.write GetLastMonth(Month(Now), Year(Now)) & "/" & GetLastMonthYear(5, 2010)  & " " & GetNextMonth(Month(Now), Year(Now)) & "/" & GetNextMonthYear(Month(Now), Year(Now))
%>
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7