Extract Some Number To Be Year

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all...

how to extract number this below :

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]data[/TD]
[TD]expected result (year)[/TD]
[/TR]
[TR]
[TD]1997-12-269[/TD]
[TD]1997[/TD]
[/TR]
[TR]
[TD]2000-12-1153[/TD]
[TD]2000[/TD]
[/TR]
[TR]
[TD]2006-2-349[/TD]
[TD]2006[/TD]
[/TR]
[TR]
[TD]2015-09-0000215[/TD]
[TD]2015[/TD]
[/TR]
[TR]
[TD]2010-05-009[/TD]
[TD]2010[/TD]
[/TR]
[TR]
[TD]2010-06-00002654[/TD]
[TD]2011[/TD]
[/TR]
[TR]
[TD]2010-07-000023[/TD]
[TD]2011[/TD]
[/TR]
[TR]
[TD]2011-01-326[/TD]
[TD]2011[/TD]
[/TR]
</tbody>[/TABLE]

criteria:
- if data ">=July 2010" ----show 2011
- if data "<july 2010"="" ----show="" <font="" color="#ff0000">2010

note just clue :
e.g. 2010-05-009 ===2010 as year, 05 as month....


thank for your helps..

m.susanto


</july>
 
Assume your date start on A1

put on B2 and copied down:

=IF(AND(DATE(2010,7,1)>=DATE(LEFT(A1,4)+0,TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",99)),100,99))+0,1),DATE(2010,7,1)<=DATE(LEFT(A1,4)+0,TRIM(MID(SUBSTITUTE(A1,"-",REPT(" ",99)),100,99))+0,1)),LEFT(A1,4)+0+1,LEFT(A1,4)+0)
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
hi Ricks...
i want to explain any more but my language not enough well, i just to illustrated with direct my case but the core :
only in 2010 increase by 1 with criteria between >=july 2010 to Dec 2010 the result is 2011 the for otherwise year (not 2010) must take 4 digits left number, like eg.

1995-05-xxxxx -----1995
2001-12-xxxxx------2001
2015-11-xxxxx------2015
2010-06-xxxxx------2010
2010-07-xxxxx------2011
2011-01-xxxxx------2011

I am not sure I understand the logic that restricts adding 1 for July thru December of 2010 only, but it that is what you want, give this formula a try...

=LEFT(A2,4)+AND(LEFT(A2,4)="2010",0+MID(A2,6,1+(MID(A2,7,1)<>"-"))>6)
 
Upvote 0
I am not sure I understand the logic that restricts adding 1 for July thru December of 2010 only, but it that is what you want, give this formula a try...

=LEFT(A2,4)+AND(LEFT(A2,4)="2010",0+MID(A2,6,1+(MID(A2,7,1)<>"-"))>6)

hi Ricks, great work, that's i mean!!! thank u
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top