Please Help with this problem

%3CLINGO-SUB%20id%3D%22lingo-sub-2597058%22%20slang%3D%22en-US%22%3EPlease%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597058%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20this%20data%2C%2010%207%202021%2010%3A00(d%20m%20yyyy%20h%3Amm)%20without%20%22%2F%22%20or%20%22-%22%20just%20space%20between%20in%20A2%2C%3C%2FP%3E%3CP%3Eand%2011%207%202021%2010%3A00%20in%20B2%20I%20just%20trying%20this%20%3D(A2-B2)%2B1%20but%20can't%2C%20i%20already%20try%20custom%20format%20but%20still%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Equestion%3A%3C%2FP%3E%3CP%3E1.%20date%20must%20have%20%22%2F%22%20or%20%22-%22%3F%3C%2FP%3E%3CP%3E2.%20can%20i%20just%20change%20my%20data%20without%20change%20it%20manually%3F%20i%20have%20very%20much%20data%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20Help%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2597058%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597378%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597378%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1117454%22%20target%3D%22_blank%22%3E%40Rian_Pramana%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20default%20date%20format%20is%20d%2Fm%2Fyyyy%20when%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DSUBSTITUTE(SUBSTITUTE(B2%2C%20%22%20%22%2C%22%2F%22%2C1)%2C%20%22%20%22%2C%22%2F%22%2C1)-%0A%20SUBSTITUTE(SUBSTITUTE(A2%2C%20%22%20%22%2C%22%2F%22%2C1)%2C%20%22%20%22%2C%22%2F%22%2C1)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597234%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597234%22%20slang%3D%22en-US%22%3Ehahahah%20i%20really%20confused%20with%20the%20proggrammer%20right%20now%20who%20give%20me%20that%20data%20format%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597233%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597233%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethankyou%20so%20much%2C%20i%20will%20try%20it..%20good%20to%20know%20it%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597206%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597206%22%20slang%3D%22en-US%22%3EWow%20thankyou%20so%20much%2C%20it%20works%20very%20well%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597109%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597109%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1117454%22%20target%3D%22_blank%22%3E%40Rian_Pramana%3C%2FA%3E%26nbsp%3Bas%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3Bsaid%2C%20using%20power%20query%20is%20the%20most%20efficient%20way%20to%20handle%20this%20scenario.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20other%20way%20you%20may%20try%3C%2FP%3E%3COL%3E%3CLI%3Esplit%20the%20time%20to%20a%20different%20column%20using%20%22Text%20to%20Columns%22%2C%20%22fixed-width%22.%20You%20will%20get%20it%20as%20below%20B%20and%20C%3C%2FLI%3E%3CLI%3Ereplace%20the%20%22space%22%20with%20%22%2F%22%20or%20%22-%22%20in%20B%3C%2FLI%3E%3CLI%3Emerge%20the%20B%20and%20C%20after%20replacing%20with%20a%20simple%20function.%3C%2FLI%3E%3C%2FOL%3E%3CTABLE%20border%3D%221%22%20width%3D%2270%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2216.71270718232044%25%22%3EA%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3EB%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3EC%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3ED%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2216.71270718232044%25%22%3EIn%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3EIn%20Date%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3EIn%20Time%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3EIn%20Combined%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2216.71270718232044%25%22%3E10%207%202021%26nbsp%3B10%3A10%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3E10%207%202021%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3E10%3A10%3C%2FTD%3E%3CTD%20width%3D%2216.574585635359114%25%22%3E10-7-2021%2010%3A10%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597080%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597080%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1117454%22%20target%3D%22_blank%22%3E%40Rian_Pramana%3C%2FA%3E%26nbsp%3BYou%20mention%20the%20you%20have%20%22very%20much%20data%22.%20That%20suggests%20that%20PowerQuery%20(PQ)%20is%20the%20solution%20to%20your%20problem.%20If%20you%20have%20never%20used%20it%20before%20it%20may%20be%20a%20bit%20overwhelming%20to%20get%20started.%20But%20once%20you%20master%20the%20basics%2C%20a%20new%20world%20will%20open%20up%20and%20it%20will%20change%20the%20way%20how%20you%20work%20with%20data%20in%20Excel%20in%20the%20future.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPQ%20allows%20you%20to%20connect%20to%20your%20raw%20data%2C%20transform%20and%20clean%20it%20and%20create%20a%20usable%20format%2C%20do%20calculations%20and%20create%20the%20kind%20of%20output%20you%20described.%20The%20attached%20file%20is%20how%20it%20could%20look%20like.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-08-01%20at%2009.04.11.png%22%20style%3D%22width%3A%20530px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299717iC9F35369CF17E83D%2Fimage-dimensions%2F530x109%3Fv%3Dv2%22%20width%3D%22530%22%20height%3D%22109%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-08-01%20at%2009.04.11.png%22%20alt%3D%22Screenshot%202021-08-01%20at%2009.04.11.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EColumns%20A%20and%20B%20hold%20text%20data%20like%20in%20your%20example.%20The%20green%20table%20was%20created%20by%20PQ.%3C%2FP%3E%3CP%3EBy%20the%20way%2C%20in%20your%20question%20you%20mentioned%20a%20formula%20like%20A-B%2B1.%20With%20dates%2Ftimes%20in%20column%20B%20that%20are%20after%20the%20ones%20in%20column%20A%2C%20that%20didn't%20seem%20to%20make%20much%20sense.%20So%2C%20in%20the%20attached%20example%20I%20calculated%20duration%20as%20B%20-%20A.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2597072%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20Help%20with%20this%20problem%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2597072%22%20slang%3D%22en-US%22%3Eyes%20date%20should%20have%20%2F%20otherwise%20excel%20will%20think%20its%20text%2C%20and%20in%20text%20you%20cant%20us%20arithmatic%20operators%3C%2FLINGO-BODY%3E
New Contributor

I have this data, 10 7 2021 10:00(d m yyyy h:mm) without "/" or "-" just space between in A2,

and 11 7 2021 10:00 in B2 I just trying this =(A2-B2)+1 but can't, i already try custom format but still

 

question:

1. date must have "/" or "-"?

2. can i just change my data without change it manually? i have very much data 

 

Please Help

7 Replies
yes date should have / otherwise excel will think its text, and in text you cant us arithmatic operators

@Rian_Pramana You mention the you have "very much data". That suggests that PowerQuery (PQ) is the solution to your problem. If you have never used it before it may be a bit overwhelming to get started. But once you master the basics, a new world will open up and it will change the way how you work with data in Excel in the future.

 

PQ allows you to connect to your raw data, transform and clean it and create a usable format, do calculations and create the kind of output you described. The attached file is how it could look like.

Screenshot 2021-08-01 at 09.04.11.png

Columns A and B hold text data like in your example. The green table was created by PQ.

By the way, in your question you mentioned a formula like A-B+1. With dates/times in column B that are after the ones in column A, that didn't seem to make much sense. So, in the attached example I calculated duration as B - A. 

 

@Rian_Pramana as @Riny_van_Eekelen said, using power query is the most efficient way to handle this scenario. 

 

One other way you may try

  1. split the time to a different column using "Text to Columns", "fixed-width". You will get it as below B and C
  2. replace the "space" with "/" or "-" in B
  3. merge the B and C after replacing with a simple function.
ABCD
InIn DateIn TimeIn Combined
10 7 2021 10:1010 7 202110:1010-7-2021 10:10

 

Hope this helps.

Wow thankyou so much, it works very well

@Riny_van_Eekelen 

 

thankyou so much, i will try it.. good to know it

hahahah i really confused with the proggrammer right now who give me that data format

@Rian_Pramana 

If default date format is d/m/yyyy when

=SUBSTITUTE(SUBSTITUTE(B2, " ","/",1), " ","/",1)-
 SUBSTITUTE(SUBSTITUTE(A2, " ","/",1), " ","/",1)