+ Reply to Thread
Results 1 to 12 of 12

Extract Date To Year With Criteria

  1. #1
    Forum Contributor
    Join Date
    01-22-2013
    Location
    Pekanbaru, Indonesia
    MS-Off Ver
    Excel 2013 & Google Sheet
    Posts
    1,146

    Extract Date To Year With Criteria

    hi..

    i have data contains date and text format, i want take year with criteria :
    if date between ">=July 2010 to Dec 2010" take 2011 otherwise like this below :

    30/12/1986----1986
    30/7/2012-----2012
    1996-08-0125--1996
    2015-12-4526--2015

    sorry, i want to single formula not helper column

    please, check my attachment..

    john m
    Attached Files Attached Files

  2. #2
    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,058

    Re: Extract Date To Year With Criteria

    Hi. I am a bit confused by the dates in the first few rows. What is the 105th July 2010???

    =IF(ISNUMBER(A2),IF(AND(A2>=DATE(2010,7,1),A2<=DATE(2010,12,31)),2011,YEAR(A2)),LEFT(A2,4))

    does almost everything you wanted, except for the 105th July!!! Can you explain what that cell (A4) is meant to represent???
    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

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Extract Date To Year With Criteria

    d6=if(And(A6>$F$1,A6<$F$2),2011,year(A6))

    in which f1 = 01-07-2010
    in which f2 = 31-12-2010
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  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,058

    Re: Extract Date To Year With Criteria

    OK. I decided to guess what you wanted... and came up with this, which seems to do what you asked for!!

    =IF(ISNUMBER(A4),IF(AND(A4>=DATE(2010,7,1),A4<=DATE(2010,12,31)),2011,YEAR(A4)),IF(AND(--LEFT(A4,4)=2010,--MID(A4,6,2)>=7),2011,LEFT(A4,4)))
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 09-13-2015 at 10:24 AM.

  5. #5
    Forum Contributor
    Join Date
    01-22-2013
    Location
    Pekanbaru, Indonesia
    MS-Off Ver
    Excel 2013 & Google Sheet
    Posts
    1,146

    Re: Extract Date To Year With Criteria

    Quote Originally Posted by Glenn Kennedy View Post
    OK. I decided to guess what you wanted... and came up with this, which seems to do what you asked for!!

    =IF(ISNUMBER(A4),IF(AND(A4>=DATE(2010,7,1),A4<=DATE(2010,12,31)),2011,YEAR(A4)),IF(AND(--LEFT(A4,4)=2010,--MID(A4,6,2)>=7),2011,LEFT(A4,4)))
    hi Glenn, working like a charm....

    thanks a lot!!!!!!

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract Date To Year With Criteria

    Or this

    =IFERROR(IF(AND(MONTH(A2)>=7,YEAR(A2)=2010),2011,YEAR(A2)),--LEFT(A2,4))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Extract Date To Year With Criteria

    This looks a crosspost to me.

    If so, please read the forumrules about crossposting.

    http://www.mrexcel.com/forum/excel-q...s-formula.html

  8. #8
    Forum Contributor
    Join Date
    04-15-2015
    Location
    beirut
    MS-Off Ver
    2010
    Posts
    107

    Re: Extract Date To Year With Criteria

    USE THIS FORMULA IN C2 (see attachment)
    PHP Code: 
    =CHOOSE(ISNUMBER(A2)+1,IF(ISTEXT(A2),IF(MONTH((MID(A2,1,LEN(A2)-1))*1)<7,YEAR((MID(A2,1,LEN(A2)-1))*1),YEAR((MID(A2,1,LEN(A2)-1))*1)+1),""),IF(ISNUMBER(A2),IF(AND(MONTH(A2)>=7,MONTH(A2)<=12,YEAR(A2)=2010),2011,YEAR(A2)),"")) 
    Attached Files Attached Files

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract Date To Year With Criteria

    an improved one

    =IF(AND(--TEXT(LEFT(A2,10),"YYYY")=2010,--TEXT(LEFT(A2,10),"m")>=7),2011,--TEXT(LEFT(A2,10),"YYYY"))

  10. #10
    Forum Contributor
    Join Date
    01-22-2013
    Location
    Pekanbaru, Indonesia
    MS-Off Ver
    Excel 2013 & Google Sheet
    Posts
    1,146

    Re: Extract Date To Year With Criteria

    hi guys...i found new problem for

    1989-1-1054 ----#value---should be 1989
    2006-6-15 -----#value---should be 2006
    etc..

    if number's month = 2 character the formula is working well otherwise not working
    1989-01-1054----1989
    2006-06-15------2006

    how do fixed?

  11. #11
    Forum Contributor
    Join Date
    04-15-2015
    Location
    beirut
    MS-Off Ver
    2010
    Posts
    107

    Re: Extract Date To Year With Criteria

    Quote Originally Posted by salim ali View Post
    USE THIS FORMULA IN C2 (see attachment)
    PHP Code: 
    =CHOOSE(ISNUMBER(A2)+1,IF(ISTEXT(A2),IF(MONTH((MID(A2,1,LEN(A2)-1))*1)<7,YEAR((MID(A2,1,LEN(A2)-1))*1),YEAR((MID(A2,1,LEN(A2)-1))*1)+1),""),IF(ISNUMBER(A2),IF(AND(MONTH(A2)>=7,MONTH(A2)<=12,YEAR(A2)=2010),2011,YEAR(A2)),"")) 
    See the 2nd sheet of this file
    EXTRACT DATE Salim 1.xlsx

  12. #12
    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,058

    Re: Extract Date To Year With Criteria

    or... just by extending the formula that I used the first time like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    will do it.

    It would also be possible to adapt Alkey's tidier solution, but it would depend on what digits can appear in the last group in A 1 to A3. Is 405 or 656 (ie anything where the first two digits exceed the number of days in a month) possible?
    Last edited by Glenn Kennedy; 09-14-2015 at 02:41 AM.

+ 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. Excel Extract Year from Text String Date
    By Ankit_Kumar in forum Excel General
    Replies: 2
    Last Post: 07-15-2015, 12:16 AM
  2. [SOLVED] How to extract last 2 digits from date year in next column?
    By mso3 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-02-2014, 12:02 PM
  3. [SOLVED] Extract Day, Month and Year from a text box (user input) date value
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-01-2014, 10:40 PM
  4. [SOLVED] Extract Year or Month only from a cell with date and time
    By djaurit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2013, 04:03 PM
  5. [SOLVED] Extract Text from String then Convert to a Date (Month/Year)
    By sgrey24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2013, 06:11 PM
  6. extract date info, disregard year
    By koticphreak in forum Excel General
    Replies: 2
    Last Post: 04-10-2009, 01:49 PM
  7. extract year from the date in a cell
    By DKY in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-17-2006, 03:10 PM

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