Consulting

Results 1 to 4 of 4

Thread: Calculating difference between months

  1. #1

    Calculating difference between months

    Hi,

    Assume I have a base-string 'May-2014' and few other related strings in a target array i.e. 'Jul-2014', 'Nov-2014', 'Dec-2014'. Now I want to calculate the number of months between base-string and target-array. Therefore I want to get an array of integer like 2, 6, 7

    Is there any VBA function available to achieve that?

    Thanks for your pointer.

  2. #2
    just subtracting the month will only work within the same year, so use a date function
    try like
    = datediff("m","may-2013","jul-2014")

  3. #3
    Is that excel function? I am getting #NAME? error in excel.

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,844
    Quote Originally Posted by arrun View Post
    Is that excel function? I am getting #NAME? error in excel.
    No, it's a vba function.
    The sheet function is
    = DATEDIF("may-2013","jul-2014","m")
    see here for documentation.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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