Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Return Number of Days In a month.

Reply
Thread Tools

Return Number of Days In a month.

 
 
Adam Knight
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 ??


 
Reply With Quote
 
 
 
 
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 ??
>
>



 
Reply With Quote
 
 
 
 
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 ??
> >
> >

>
>



 
Reply With Quote
 
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 ??
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
dlbjr
Guest
Posts: n/a
 
      05-19-2004
Function GetDaysInMonth(dtmDate)
If IsDate(dtmDate) Then
dtmFirstOfMonth = DateSerial(Year(dtmDate),Month(dtmDate),1)
GetDaysInMonth = Day(DateAdd("d",-1,DateAdd("m",1,dtmFirstOfMonth)))
End If
End Function

'from dlbjr

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


 
Reply With Quote
 
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 =

Day(DateAdd("d",-1,DateAdd("m",1,dtmFirstOfMonth)))
> End If
> End Function
>
> 'from dlbjr
>
> 'Unambit from meager knowledge of inane others,engender uncharted

sagacity.
>
>


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
De jours en jours - Octobre 2004 / Days after days - October 2004 Serge IZOARD Digital Photography 0 11-01-2004 09:07 PM
Re: Calculating days using Business Days for the Calendar Terry Reedy Python 0 09-20-2004 10:44 PM
Calculating days using Business Days for the Calendar David Stockwell Python 2 09-20-2004 09:58 PM
Re: Calculating days using Business Days for the Calendar Gerrit Python 0 09-20-2004 04:39 PM



Advertisments