+ Reply to Thread
Results 1 to 6 of 6

calculating month of present date

  1. #1
    Registered User
    Join Date
    02-13-2006
    Posts
    7

    calculating month of present date

    Hey all
    please let me know how can i calculate month of present date in VBA.
    At present i can have the first date and present date by
    txtStartDate = Format(Date - Day(Date) + 1, "dd/mm/yyyy")
    txtEndDate = Format(Date, "dd/mm/yyyy").

    but now i want to calculate MONTH of present date.

    please help
    thanks in advance

  2. #2
    Bob Phillips
    Guest

    Re: calculating month of present date

    txtMonth.Text = Month(Date)

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "anu_manu" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hey all
    > please let me know how can i calculate month of present date in VBA.
    > At present i can have the first date and present date by
    > txtStartDate = Format(Date - Day(Date) + 1, "dd/mm/yyyy")
    > txtEndDate = Format(Date, "dd/mm/yyyy").
    >
    > but now i want to calculate MONTH of present date.
    >
    > please help
    > thanks in advance
    >
    >
    > --
    > anu_manu
    > ------------------------------------------------------------------------
    > anu_manu's Profile:

    http://www.excelforum.com/member.php...o&userid=31510
    > View this thread: http://www.excelforum.com/showthread...hreadid=516246
    >




  3. #3
    Registered User
    Join Date
    02-13-2006
    Posts
    7
    Thanks Bob
    But Month(date) returns 01/01/1900 and not 02/01/2006. why is that so?
    Thanks

  4. #4
    Duke Carey
    Guest

    Re: calculating month of present date

    It is returning an integer, but you've got the cell formatted as date.
    Change the format to general or number and you'll get the date

    "anu_manu" wrote:

    >
    > Thanks Bob
    > But Month(date) returns 01/01/1900 and not 02/01/2006. why is that so?
    > Thanks
    >
    >
    > --
    > anu_manu
    > ------------------------------------------------------------------------
    > anu_manu's Profile: http://www.excelforum.com/member.php...o&userid=31510
    > View this thread: http://www.excelforum.com/showthread...hreadid=516246
    >
    >


  5. #5
    Registered User
    Join Date
    02-13-2006
    Posts
    7

    Exclamation

    i format it as this

    Format(month(date),"mm/dd/yyyy")

    isn't it right?

    Actually,my problem is this..

    Currently the Start Date defaults to the first day of the current month.
    The request is to default the start date to the first day of the quarter
    (e.g. 01.01, 04.01,07.01,10.01... +year).

    If the current month is between 1 and 3, default is 01.01.+current year
    If the current month is between 4 and 6, default is 04.01.+current year

    Please kindly guide.

  6. #6
    Bob Phillips
    Guest

    Re: calculating month of present date

    StartDate = DateSerial(Year(StartDate), (Month(StartDate) + 2) \ 3, 1)


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "anu_manu" <[email protected]> wrote in
    message news:[email protected]...
    >
    > i format it as this
    >
    > Format(month(date),"mm/dd/yyyy")
    >
    > isn't it right?
    >
    > Actually,my problem is this..
    >
    > Currently the Start Date defaults to the first day of the current
    > month.
    > The request is to default the start date to the first day of the
    > quarter
    > (e.g. 01.01, 04.01,07.01,10.01... +year).
    >
    > If the current month is between 1 and 3, default is 01.01.+current
    > year
    > If the current month is between 4 and 6, default is 04.01.+current
    > year
    >
    > Please kindly guide.
    >
    >
    > --
    > anu_manu
    > ------------------------------------------------------------------------
    > anu_manu's Profile:

    http://www.excelforum.com/member.php...o&userid=31510
    > View this thread: http://www.excelforum.com/showthread...hreadid=516246
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1