Date Change

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,132
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
Not sure as it is not converting the date,
the data is there, the code is not convert mm/dd/yyyy to dd-mm-yyyy

the problem is if till 12 day of any month the date come as mm/dd/yyyy and as it 13 day of any month then the input file comes as dd-mm-yyyy

so need a code that will fix the to dd-mm-yyyy always.

VBA Code:
Sub datachange()

Application.Wait (Now + TimeValue("0:00:02"))
  Range("B2:B80000").TextToColumns Destination:=Range("B2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 4), TrailingMinusNumbers:=False
  Range("B2:B80000").NumberFormat = "dd-mm-yyyy"

End Sub

Book3
B
1CREADTED_DATE
22/11/2023
331-10-2023
431-10-2023
531-10-2023
631-10-2023
71/11/2023
81/11/2023
91/11/2023
101/11/2023
111/11/2023
121/11/2023
132/11/2023
1431-10-2023
1531-10-2023
1631-10-2023
1731-10-2023
1831-10-2023
1931-10-2023
2031-10-2023
2131-10-2023
2231-10-2023
231/11/2023
Sheet1
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Is the data you showed here the values before you run your code? Or after?
 
Upvote 0
Not sure about your question, what you have posted is all in day, month, year format
 
Upvote 0
The problem is not in the format you are applying, it is in your data.

Your initial data is ambiguous. Do you expect 2/11/2023 to be interpreted as Nov 2 or Feb 11?

What are your localization settings in Excel/Windows for default date format?
 
Upvote 0
Not sure about your question, what you have posted is all in day, month, year format
yes all is in dd mm yyyy but as the date cahnges to 13 the input data comes as 13-11-2023 its 13 Nov and till 12 day its input comes in as 12/11/2023 its 12 Nov,

so need to modifity all the dates in dd-mm-yyyy formate, if the input file is in dd/mm/yyy or dd-mm-yyyy final output should be in dd-mm-yyyy only.
 
Upvote 0
If you run the code below on the original data, can you post the result please?

VBA Code:
Sub datachange()
Range("B2:B80000").TextToColumns Destination:=Range("B2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 4), TrailingMinusNumbers:=False
 Range("B2:B80000").NumberFormat = "General"

End Sub

Can you also select and copy the original data and paste it directly in the thread please (without using XL2BB)
 
Last edited:
Upvote 0
a
Sub datachange() Range("B2:B80000").TextToColumns Destination:=Range("B2"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _ Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _ :=Array(1, 4), TrailingMinusNumbers:=False Range("B2:B80000").NumberFormat = "General"
after running this the result, and orignial data i have already share on my 1 st post in xl2bb

WEKCREADTED_DATE
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
44​
45230​
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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