Date Calculation

C

colleen1980

Hi: Can any one please tell me how to i calculate the next month
starting day and next month ending date. For example if this is january
then i need the next month that is february starting day and february
ending day. I need to calculate the date in that way given below, I
mean without query. Below method is i use it to calculate the todays
date and the end of the day.

MonthLastDay = Empty
dFirstDayNextMonth = DateSerial(CInt(Format(dCurrDate, "yyyy")),
CInt(Format(dCurrDate, "mm")) + 1, 1)
MonthLastDay = DateAdd("d", -1, dFirstDayNextMonth)

Thanks,
Anna.
 
E

Evertjan.

(e-mail address removed) wrote on 22 jan 2007 in
microsoft.public.inetserver.asp.general:
Hi: Can any one please tell me how to i calculate the next month
starting day and next month ending date. For example if this is january
then i need the next month that is february starting day and february
ending day. I need to calculate the date in that way given below, I
mean without query. Below method is i use it to calculate the todays
date and the end of the day.

MonthLastDay = Empty
dFirstDayNextMonth = DateSerial(CInt(Format(dCurrDate, "yyyy")),
CInt(Format(dCurrDate, "mm")) + 1, 1)
MonthLastDay = DateAdd("d", -1, dFirstDayNextMonth)

======== vbscript

today = Date()
curYear = Year(today)
nextMonth = Month(DateAdd("m", 1, today))
nextNextMonth = Month(DateAdd("m", 2, today))

firstDayNextMonth = _
DateSerial(curYear, nextMonth, 1)

lastDayNextMonth = _
DateAdd("d",-1,DateSerial(curYear,nextNextMonth,1))

=====================
 
E

Evertjan.

Evertjan. wrote on 22 jan 2007 in microsoft.public.inetserver.asp.general:
today = Date()
curYear = Year(today)
nextMonth = Month(DateAdd("m", 1, today))
nextNextMonth = Month(DateAdd("m", 2, today))

firstDayNextMonth = _
DateSerial(curYear, nextMonth, 1)

lastDayNextMonth = _
DateAdd("d",-1,DateSerial(curYear,nextNextMonth,1))

Sorry, that was wrong, too quick with the "send" button.

Try [vbscript]:

===============

today = Date()

d = DateAdd("m", 1, today)
d = DateSerial(year(d), month(d), 1)
firstDayNextMonth = d


d = DateAdd("m", 2, today)
d = DateSerial(year(d), month(d), 1)
lastDayNextMonth = DateAdd("d", -1, d)

===============
 
E

Evertjan.

Dave Anderson wrote on 25 jan 2007 in
microsoft.public.inetserver.asp.general:
You can even simplify this further:

d = DateAdd("m", 2, today)
lastDayNextMonth = DateSerial(year(d), month(d), -1)

I was not sure, and did not test. ;-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top