Mixed Date Formats in the same Column

Status
Not open for further replies.

paulfitz320

Board Regular
Joined
Jan 6, 2007
Messages
122
Office Version
  1. 365
Platform
  1. Windows
I have a big spreadsheet, some 750000 rows.

In Column C I have dates.

Approximately half of the dates in this Column are in dd/mm/yyyy format, the other half in mm/dd/yyyy format, I think.

eg. 31/05/2012
then 01/06/2012 (appears as 06/01/2012 in the formula window)

Any help to get them ALL to dd/mm/yyyy really appreciated.
 
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi Akuini

Thank you for responding to this query.

I tried using this micro but it doesn't seem to be working for me

Please can you help as I'm having the same issue.

Is it correct to assume that if first 2 number is less than 13 then it must be the false date?
If yes then try this (in small data first):


Code:
Sub flipDate()
Dim va, x
Dim i As Long
va = Range("C2", Cells(Rows.count, "C").End(xlUp))
For i = 1 To UBound(va, 1)
    x = va(i, 1)
    If Left(x, 2) < 13 Then va(i, 1) = DateSerial(Right(x, 4), Left(x, 2), Mid(x, 4, 2))
Next
Range("C2").Resize(UBound(va, 1), 1) = va
End Sub
 
Upvote 0
Hi, AfuaImade
The OP's data problem is like this:
If the first 2 numbers are less than 13 then it means the date is wrong (meaning the days & months have been swapped).

Could you explain your data problem?
Could you explain 'doesn't seem to be working'? Did the code produce a wrong result?
And could you post some data as table?
 
Upvote 0
Hello Akuini,

Thanks for responding. Below is a sample of the data

7851203

<tbody>
</tbody>
Approved

<tbody>
</tbody>
12/4/2019 23:14

<tbody>
</tbody>
7851569

<tbody>
</tbody>
Approved

<tbody>
</tbody>
12/4/2019 23:22

<tbody>
</tbody>
1243752

<tbody>
</tbody>
Approved by Financial Institution

<tbody>
</tbody>
13/04/2019 0:10

<tbody>
</tbody>
7852253

<tbody>
</tbody>
Approved by Financial Institution

<tbody>
</tbody>
13/04/2019 0:30

<tbody>
</tbody>
1657054

<tbody>
</tbody>
Approved

<tbody>
</tbody>
12/5/2019 23:38

<tbody>
</tbody>
7947320

<tbody>
</tbody>
Kindly enter the OTP sent to 234813***8577

<tbody>
</tbody>
12/5/2019 23:40

<tbody>
</tbody>
5347509

<tbody>
</tbody>
Approved

<tbody>
</tbody>
13/05/2019 0:12

<tbody>
</tbody>
5268985

<tbody>
</tbody>
Approved

<tbody>
</tbody>
13/05/2019 0:49

<tbody>
</tbody>
1066630

<tbody>
</tbody>
The bank is currently unable to process this transaction. Please try another card or bank account.

<tbody>
</tbody>
12/6/2019 23:21

<tbody>
</tbody>
8851513

<tbody>
</tbody>
Approved by Financial Institution

<tbody>
</tbody>
13/06/2019 0:33

<tbody>
</tbody>

<tbody>
</tbody>

The data is specifically for month 4,5,6 (ie April,May,June) so therefore I know that even if the first 2 numbers are less than 13, it doesn't mean that the date as in the first row is not December but April.

When I ran the code, I got the error below highlighted in Yellow

If Left(x, 2) < 13 Then va(i, 1) = DateSerial(Right(x, 4), Left(x, 2), Mid(x, 4, 2))


Hi, AfuaImade
The OP's data problem is like this:
If the first 2 numbers are less than 13 then it means the date is wrong (meaning the days & months have been swapped).

Could you explain your data problem?
Could you explain 'doesn't seem to be working'? Did the code produce a wrong result?
And could you post some data as table?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,267
Messages
6,123,964
Members
449,137
Latest member
yeti1016

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