Return Number of Days In a month.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam Knight

    Return Number of Days In a month.

    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

    #2
    Re: Return Number of Days In a month.

    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" <adam.jknight@o ptusnet.com.au> wrote in message
    news:enbUMJaPEH A.1048@tk2msftn gp13.phx.gbl...[color=blue]
    > 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 ??
    >
    >[/color]


    Comment

    • TomB

      #3
      Re: Return Number of Days In a month.

      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:eWXNSZaPEH A.2704@TK2MSFTN GP10.phx.gbl...[color=blue]
      > 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" <adam.jknight@o ptusnet.com.au> wrote in message
      > news:enbUMJaPEH A.1048@tk2msftn gp13.phx.gbl...[color=green]
      > > 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 ??
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Ray at

        #4
        Re: Return Number of Days In a month.

        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" <shuckle@hotmai lXXX.com> wrote in message
        news:uI$%23CSdP EHA.2452@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > 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:eWXNSZaPEH A.2704@TK2MSFTN GP10.phx.gbl...[color=green]
        > > 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[/color][/color]
        year,[color=blue][color=green]
        > > do:
        > >
        > > yourDate = yourYear & "-" & yourMonth & "-1"
        > >
        > > What the code above is doing is taking your date, adding one month to[/color][/color]
        it,[color=blue][color=green]
        > > then subtracting one day.
        > >
        > > Ray at work
        > >
        > >
        > > "Adam Knight" <adam.jknight@o ptusnet.com.au> wrote in message
        > > news:enbUMJaPEH A.1048@tk2msftn gp13.phx.gbl...[color=darkred]
        > > > I am wanting to create my own calendar asp module.
        > > >
        > > > Are there any functions in vbscript that return the number of days in[/color][/color][/color]
        a[color=blue][color=green][color=darkred]
        > > > particular month depending on what year it is ??
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • dlbjr

          #5
          Re: Return Number of Days In a month.

          Function GetDaysInMonth( dtmDate)
          If IsDate(dtmDate) Then
          dtmFirstOfMonth = DateSerial(Year (dtmDate),Month (dtmDate),1)
          GetDaysInMonth = Day(DateAdd("d" ,-1,DateAdd("m",1 ,dtmFirstOfMont h)))
          End If
          End Function

          'from dlbjr

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


          Comment

          • Chris Hohmann

            #6
            Re: Return Number of Days In a month.

            "dlbjr" <oops@iforgot.c om> wrote in message
            news:eXRy$FePEH A.2996@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Function GetDaysInMonth( dtmDate)
            > If IsDate(dtmDate) Then
            > dtmFirstOfMonth = DateSerial(Year (dtmDate),Month (dtmDate),1)
            > GetDaysInMonth =[/color]
            Day(DateAdd("d" ,-1,DateAdd("m",1 ,dtmFirstOfMont h)))[color=blue]
            > End If
            > End Function
            >
            > 'from dlbjr
            >
            > 'Unambit from meager knowledge of inane others,engender uncharted[/color]
            sagacity.[color=blue]
            >
            >[/color]

            Day(DateSerial( Year(dtmDate),M onth(dtmDate)+1 ,0))


            Comment

            Working...