Velocity Reviews > Return Number of Days In a month.

# Return Number of Days In a month.

Guest
Posts: n/a

 05-19-2004
I am wanting to create my own calendar asp module.

Are there any functions in vbscript that return the number of days in a
particular month depending on what year it is ??

Ray at
Guest
Posts: n/a

 05-19-2004
You could do this:

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

If you don't have a value of "yourDate" and just have a month and a year,
do:

yourDate = yourYear & "-" & yourMonth & "-1"

What the code above is doing is taking your date, adding one month to it,
then subtracting one day.

Ray at work

"Adam Knight" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am wanting to create my own calendar asp module.
>
> Are there any functions in vbscript that return the number of days in a
> particular month depending on what year it is ??
>
>

TomB
Guest
Posts: n/a

 05-19-2004
Ray,

iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))

DateAdd("m",1, yourDate) -- so it goes to June 19 (assuming yourDate is
May19)
DateAdd("d",-1,theAbove) -- so it goes to June 18
Day(theAbove) -- 18

Am I missing something?

TomB

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:(E-Mail Removed)...
> You could do this:
>
> iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))
>
> If you don't have a value of "yourDate" and just have a month and a year,
> do:
>
> yourDate = yourYear & "-" & yourMonth & "-1"
>
> What the code above is doing is taking your date, adding one month to it,
> then subtracting one day.
>
> Ray at work
>
>
> "Adam Knight" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I am wanting to create my own calendar asp module.
> >
> > Are there any functions in vbscript that return the number of days in a
> > particular month depending on what year it is ??
> >
> >

>
>

Ray at
Guest
Posts: n/a

 05-19-2004
I was going with a "yourDate" as being the first of the month. If it's just
an arbitrary date, then you (or Adam?) could do:

myDate = "2004-05-19"
yourDate = Year(myDate) & "-" & Month(myDate) & "-1"

first. That will then do:
- go to beginning of month
- add one month
- subtract one day

Ray at work

"TomB" <(E-Mail Removed)> wrote in message
news:uI\$%(E-Mail Removed)...
> Ray,
>
> iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))
>
> DateAdd("m",1, yourDate) -- so it goes to June 19 (assuming yourDate is
> May19)
> DateAdd("d",-1,theAbove) -- so it goes to June 18
> Day(theAbove) -- 18
>
> Am I missing something?
>
>
> TomB
>
>
> "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
> message news:(E-Mail Removed)...
> > You could do this:
> >
> > iDays = Day(DateAdd("d", -1, DateAdd("m", 1, yourDate)))
> >
> > If you don't have a value of "yourDate" and just have a month and a

year,
> > do:
> >
> > yourDate = yourYear & "-" & yourMonth & "-1"
> >
> > What the code above is doing is taking your date, adding one month to

it,
> > then subtracting one day.
> >
> > Ray at work
> >
> >
> > "Adam Knight" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I am wanting to create my own calendar asp module.
> > >
> > > Are there any functions in vbscript that return the number of days in

a
> > > particular month depending on what year it is ??
> > >
> > >

> >
> >

>
>

dlbjr
Guest
Posts: n/a

 05-19-2004
Function GetDaysInMonth(dtmDate)
If IsDate(dtmDate) Then
dtmFirstOfMonth = DateSerial(Year(dtmDate),Month(dtmDate),1)
End If
End Function

'from dlbjr

'Unambit from meager knowledge of inane others,engender uncharted sagacity.

Chris Hohmann
Guest
Posts: n/a

 05-19-2004
"dlbjr" <(E-Mail Removed)> wrote in message
news:eXRy\$(E-Mail Removed)...
> Function GetDaysInMonth(dtmDate)
> If IsDate(dtmDate) Then
> dtmFirstOfMonth = DateSerial(Year(dtmDate),Month(dtmDate),1)
> GetDaysInMonth =

> End If
> End Function
>
> 'from dlbjr
>
> 'Unambit from meager knowledge of inane others,engender uncharted

sagacity.
>
>

Day(DateSerial(Year(dtmDate),Month(dtmDate)+1,0))