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

Asked

Viewed 1,146 times

3

For example: we are in March 2015. I can catch the next month of the current year using month()+1 concatenating with year(), that is, the month of April 2015. However, let’s say we were in December 2015, as I automatically pick up the month of January and the year 2016? Is there any function that does this without me having to compare the month?

1 answer

1


You can add or remove time internvalos to a date with the function Dateadd, 3 it is necessary to inform 3 arguments: the interval, quantity and the date.

Ranges available

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))
%>

Exit:

12 - 2014
1 -  2016

Browser other questions tagged

You are not signed in. Login or sign up in order to post.