+ Reply to Thread
Results 1 to 11 of 11

Formula conversion from date string to numbers

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Formula conversion from date string to numbers

    Hello everyone,

    The below formula works fine for what I want to do:

    Please Login or Register  to view this content.
    The problem with my formula is that it searches for the month and year as a string “*December**2017*” etc. as the date is entered as 8th December 2017. This is fine but I need to input the date as a number now 08/12/2017 and not a string. I tried to update the formula myself using sum product but was not able to get it working. Is there any way that my formula can be changed so that it checks for the month and year as numbers and not a string? So instead of the date being input as lets say 8th December 2017 it will be put in as 08/12/2017 and the formula will work as it does now?

    My page has a lot of formulas set up like this that need to be changed but I just need to know how to do it on one so I change all of the others.

    Thank you in advance for any help.

    Regards,

    Margate : )
    Last edited by Margate; 01-13-2018 at 02:20 PM. Reason: To update the formula

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Formula conversion from date string to numbers

    I'd be inclined to use SUMPRODUCT rather than SUMIFS. You can then easily use the TEXT function to extract the month name and year.

    That said, it looks, to me, as though the IF and repeated formula is redundant. You're saying, if the SUMIFS value is zero, return 0 but, if it's not, return the SUMIFS value. Either way, you return the value of the SUMIFS.

    However, it would be easier, I think, to use the YEAR and MONTH functions to return the numeric values of the year and month and then amend your formula, or the alternative SUMPRODUCT formula, to use those numeric values instead.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Re: Formula conversion from date string to numbers

    Good point about the redundant if=0=0! I have taken that out and updated the code.
    I did try sum-product but it did not work for some reason? This is what I came up with:

    Please Login or Register  to view this content.
    Note that I have reduced the range down to just two cells. This formula returns #NAME?

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Formula conversion from date string to numbers

    Replace the " around the word accountancy with the standard " (same key as digit 2 on a UK keyboard....)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Contributor
    Join Date
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Re: Formula conversion from date string to numbers

    Done, but not instead of #NAME? I am getting #VALUE!

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Formula conversion from date string to numbers

    can you attach your workbook? I got "0" using an empty sheet called accountancy

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  7. #7
    Forum Contributor
    Join Date
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Re: Formula conversion from date string to numbers

    I have added an attachment spreadsheet.
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Formula conversion from date string to numbers

    There was some redundant text in your formula, but the main problem was that the last term was referring to column K. It should have been column N:
    =SUMPRODUCT((MONTH(Accounts!E3:E4)=12)*(YEAR(Accounts!E3:E4)=2017)*(Accounts!K3:K4="Accountancy")*(Accounts!N3:N4))

  9. #9
    Forum Contributor
    Join Date
    01-18-2013
    Location
    England
    MS-Off Ver
    2016 (Mac)
    Posts
    149

    Re: Formula conversion from date string to numbers

    Glenn,
    That works perfectly. Thank you very much for your help. I have learned for your solution. I was sort of on the right track but would never have worked it out. I will mark this as solved.

    Regards,

    Margate

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,002

    Re: Formula conversion from date string to numbers

    We all make mistakes... It's how we learn. Thanks for the rep.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Formula conversion from date string to numbers

    You're welcome. Thanks for the rep.


    To be fair, Glenn did all the work ... but thanks again, anyway

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] how to use "OR" in my function - String to Date conversion
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 09-26-2017, 07:17 AM
  2. put a string into a date but WITHOUT conversion.
    By andreagiugio in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2016, 11:56 AM
  3. Replies: 4
    Last Post: 06-26-2012, 03:35 PM
  4. String conversion formula?
    By JGTExcel in forum Excel General
    Replies: 3
    Last Post: 02-10-2012, 01:12 PM
  5. String to Date Conversion
    By dasreinfeld in forum Excel General
    Replies: 10
    Last Post: 11-18-2010, 07:15 PM
  6. Search/Replace String to Formula conversion
    By wrigax in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2008, 09:43 PM
  7. conversion to formula of string contaning IF clause
    By JeanBQ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2006, 12:55 PM

Tags for this Thread

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