Date Calculation

Date Calculation

am 22.01.2007 16:06:58 von 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.

Re: Date Calculation

am 22.01.2007 17:11:51 von exjxw.hannivoort

colleen1980@gmail.com 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))

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




--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Date Calculation

am 22.01.2007 17:24:16 von exjxw.hannivoort

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)

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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Date Calculation

am 25.01.2007 15:07:31 von Dave Anderson

Evertjan. wrote:
> d = DateAdd("m", 2, today)
> d = DateSerial(year(d), month(d), 1)
> lastDayNextMonth = DateAdd("d", -1, d)

You can even simplify this further:

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

This is identical to the JSCript behavior:

var D = new Date()
lastDayNextMonth = new Date(D.getFullYear(),D.getMonth()+2,-1)


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Re: Date Calculation

am 25.01.2007 16:04:58 von exjxw.hannivoort

Dave Anderson wrote on 25 jan 2007 in
microsoft.public.inetserver.asp.general:

> Evertjan. wrote:
>> d = DateAdd("m", 2, today)
>> d = DateSerial(year(d), month(d), 1)
>> lastDayNextMonth = DateAdd("d", -1, d)
>
> 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. ;-(

> This is identical to the JSCript behavior:
>
> var D = new Date()
> lastDayNextMonth = new Date(D.getFullYear(),D.getMonth()+2,-1)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)