Struggling with Dates/Times

MASOODAHMAD

Board Regular
Joined
Mar 28, 2012
Messages
105
Platform
  1. MacOS
Hello Everyone,

Hope you’re well.

The only Excel formulas, I always struggle with is the Date and Time formulas. I create Job Entry Reports and Dashboards for different departments in my company. Sometimes I also have to cleanup the Excel data to create a dashboard out of it. The major problem I see is with the Date column. Some people write: DD/MM/YYYY, some write MM/DD/YYYY, etc in the same column. So it is hard to figure out which is the correct date. Not only this, they sometimes copy & Paste the date from somewhere, which looks like a date but is not a date.

The first thing I do is, use the ‘ISDATE’ function to verify that it is a date or not.Then I struggle finding out whether the date entered is a DD/MM/YYYY or MM/DD/YYYY. I do all this manually, which eats up a lot of time. So is there any quickest and effective way of doing this.

In the attached Google sheet, I have tried to showcase the issues I faced with the Date and Time formulas.

In the ‘Date_Issues’ sheet, the data received form the Studio is in column B. The date has some prefixes. So, first thing I do is remove the prefixes from the dates (column D). Then I used the "ISDATE" function to see if the date is really a date or not. So, for all the FALSE conditions, I have to fix the dates manually.
Is there any quicker method to achieve this, considering the dates to be in MM/DD/YYYY format.

In the 'Time_Issues', sheet, I need to find the time difference, but I’m not getting the right results, if,
a) the date changes to the next date
b) the date changes to the next date and the out-time is higher than the in-time (more than 24 hours). See Red highlighted.

In regards to the TIME formula, let’s say, I want to find the difference between the two times, I can do it, NewTime - OldTime (column H). But the problem occurs when the day changes and so on.

I tried to expand the formula, but it still fails at many places (column F).

Can anyone please help me resolve this issue.

Have a great day.

Masood
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
@MASOODAHMAD Are you using Excel or Google Sheets?

With regards to your Date issues.
Maybe the below might give you some ideas?
It still does beg a question for those rows that return "???".
Assuming that there is still possibility for a mixture of DD/MM/YYY and MM/DD/YYY dates in A .
Is ,for example, 2/3/2022 the second of March or the third of February???
If you don't have a logical test to determine then you could have unforeseen error.

If you have influence over the data sources then your best bet would be to tighten up on format of the submitted data!

Book1
ABCDEFGH
1Actual Data ReceivedSplit Text Date of ABest Date ?
2W/B 01/25/202101 25 20211/25/21
3W/B 02/01/202102 01 2021???
4W/B 02/08/202102 08 2021???
5W/B 02/15/202102 15 20212/15/21
6W/B 03/01/202103 01 2021???
7W/B 03/08/202103 08 2021???
8W/B 03/15/202103 15 20213/15/21
9W/B 03/22/202103 22 20213/22/21
10W/B 04/05/202104 05 2021???
11W/B 04/12/202104 12 2021???
12W/B 04/19/202104 19 20214/19/21
13W/B 04/26/202104 26 20214/26/21
14W/B 05/10/202105 10 2021???
15W/B 05/17/202105 17 20215/17/21
16W/B 05/24/202105 24 20215/24/21
17W/B 06/01/202106 01 2021???
18W/B 05/03/202105 03 2021???
19W/B 05/10/202105 10 2021???
20W/B 05/17/202105 17 20215/17/21
21W/B 05/31/202105 31 20215/31/21
22W/B 06/07/202106 07 2021???
23W/B 06/14/202106 14 20216/14/21
24W/B 06/21/202106 21 20216/21/21
25W/B 06/28/202106 28 20216/28/21
26W/B 06/07/202106 07 2021???
27W/B 06/14/202106 14 20216/14/21
28W/B 06/21/202106 21 20216/21/21
29W/B 07/05/202107 05 2021???
30W/B 07/12/202107 12 2021???
31W/B 07/19/202107 19 20217/19/21
32W/B 07/26/202107 26 20217/26/21
33W/B 08/02/202108 02 2021???
34W/B 07/19/202107 19 20217/19/21
35W/B 07/26/202107 26 20217/26/21
36W/B 08/02/202108 02 2021???
37W/B 08/16/202108 16 20218/16/21
38W/B 08/23/202108 23 20218/23/21
39W/B 08/30/202108 30 20218/30/21
40W/B 09/06/202109 06 2021???
41W/B 09/13/202109 13 20219/13/21
42W/B 08/02/202108 02 2021???
43W/B 08/09/202108 09 2021???
44W/B 08/16/202108 16 20218/16/21
45W/B 08/23/202108 23 20218/23/21
46W/B 09/06/202109 06 2021???
47W/B 09/06/202109 06 2021???
48W/B 09/13/202109 13 20219/13/21
49W/B 09/20/202109 20 20219/20/21
50W/B 10/18/202110 18 202110/18/21
51W/B 10/25/202110 25 202110/25/21
52W/B 11/01/202111 01 2021???
53W/B 11/15/202111 15 202111/15/21
54W/B 11/22/202111 22 202111/22/21
55W/B 11/29/202111 29 202111/29/21
56W/B 12/06/202112 06 2021???
57W/B 12/13/202112 13 202112/13/21
58W/B 02/22/202102 22 20212/22/21
59W/B 03/01/202103 01 2021???
60W/B 03/08/202103 08 2021???
61W/B 03/09/202103 09 2021???
62W/B 03/15/202103 15 20213/15/21
63W/B 03/29/202103 29 20213/29/21
64W/B 04/05/202104 05 2021???
65W/B 04/12/202104 12 2021???
66W/B 04/19/202104 19 20214/19/21
67W/B 04/26/202104 26 20214/26/21
68W/B 05/03/202105 03 2021???
69W/B 05/04/202105 04 2021???
70W/B 05/10/202105 10 2021???
71W/B 05/17/202105 17 20215/17/21
72W/B 05/24/202105 24 20215/24/21
73W/B 05/31/202105 31 20215/31/21
74W/B 08/30/202108 30 20218/30/21
75W/B 09/06/202109 06 2021???
76W/B 09/14/202109 14 20219/14/21
77W/B 09/20/202109 20 20219/20/21
78W/B 09/20/202109 20 20219/20/21
79W/B 09/27/202109 27 20219/27/21
80W/B 10/04/202110 04 2021???
81W/B 10/11/202110 11 2021???
82W/B 2/21/20222 21 20222/21/22
83W/B 2/28/20222 28 20222/28/22
84W/B 3/7/20223 7 2022???
85W/B 3/21/20223 21 20223/21/22
86W/B 3/28/20223 28 20223/28/22
87W/B 4/4/20224 4 2022???
88W/B 4/11/20224 11 2022???
89W/B 4/18/20224 18 20224/18/22
90W/B 3/21/20213 21 20213/21/21
91W/B 3/28/20213 28 20213/28/21
92W/B 4/4/20214 4 2021???
93W/B 4/18/20214 18 20214/18/21
94W/B 4/25/20214 25 20214/25/21
95W/B 5/2/20215 2 2021???
96W/B 5/9/20215 9 2021???
97W/B 5/16/20215 16 20215/16/21
98W/B 4/18/20224 18 20224/18/22
99W/B 4/25/20224 25 20224/25/22
100W/B 5/2/20225 2 2022???
101W/B 5/16/20225 16 20225/16/22
102W/B 13/12/202213 12 202212/13/22
103W/B 21/7/202321 7 20237/21/23
Sheet1
Cell Formulas
RangeFormula
G2:G103G2=SUBSTITUTE(TRIM(SUBSTITUTE(B2,"W/B","")),"/"," ")
H2:H103H2=IF(VALUE(LEFT(G2,3))>12,DATE(RIGHT(G2,4),MID(G2,5,6),LEFT(G2,3)),IF(AND(VALUE(LEFT(G2,4))<13,VALUE(MID(G2,5,6))<13),"???",DATE(RIGHT(G2,4),LEFT(G2,3),MID(G2,5,6))))
 
Upvote 0
Thanks @Snakehips, The solution seems quite complex but I'll try this some day.

I use both MS Excel and Googlesheets. Since we're on Google Network, we prefer using Googlesheets over MS Excel.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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