How to get the next month and year in classic ASP?

3

For example: this is March 2015. I can get the next month of the current year using month()+1 concatenating with year() , ie the month of April 2015. But let's say we were in December 2015 , how do I automatically get the month of January and the year 2016 ? Is there any function that does this without me having to make comparison of the month?

    
asked by anonymous 24.03.2015 / 23:34

1 answer

1

You can add or remove time maps to a date with the DateAdd , 3 you need to enter 3 arguments: the range, quantity, and date.

Available ranges

yyyy |  Ano
q    |  Quarto
m    |  Mês
y    |  Dia do ano
d    |  Dia
w    |  Dia da semana
ww   |  Semana
h    |  Hora
n    |  Minuto
s    |  Segundo

Example:

<% 
  data = "2015-01-01"
  response.write month(DateAdd("m", -1, data)) &" - "& year(DateAdd("m", -1, data))
  response.write month(DateAdd("m", 12, data)) &" - "& year(DateAdd("m", 12, data))
%>

Output:

12 - 2014
1 -  2016
    
25.03.2015 / 12:20