Results 1 to 4 of 4

Thread: [RESOLVED] Build array of month

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Resolved [RESOLVED] Build array of month

    How can I easily build an array using current month as starting point and build 12 buckets where bucket 1 = current month -1 month, bucket 2 = current month -2 month and so on..... Thank you.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Build array of month

    DateTime.Now.Month will give you the current month number. Create a loop for 1 to 12, and keep subtracting (DateTime.Now.AddMonths(-4)). But that is in itself irrelevant - each bucket is simply numbered and can represent the amount to subtract by. Is that all you really need or is there a bigger context to the buckets?

  3. #3

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Re: Build array of month

    I managed this way, not the best code though..


    Code:
    For i = 0 To myNewMonth.Length - 1
                myNewdate = DateTime.Now.AddMonths(-i - 1).ToString
                myNewMonth(i) = Month(myNewdate).ToString() & "/" & Year(myNewdate)
    Next i

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Build array of month

    Hey,

    I would recommend that you have you a look at the DateTime Members available here:

    http://msdn.microsoft.com/en-us/libr...e_members.aspx

    There is no reason why you need to do the methods that you are using for Month and Year, these are already available as properties on the DateTime class.

    Gary

Posting Permissions

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



Click Here to Expand Forum to Full Width