010407 to 1/4/2007

QuietRiot

Well-known Member
Joined
May 18, 2007
Messages
1,079
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. MacOS
how could I get date from 010407 to 1/4/2007

VBA or formula would be helpful

i will be using it in code though.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
If your orignal dates are text, not numbers formatted that way, then perhaps something like this:

Code:
Sub Test()
Range("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, FieldInfo:=Array(1, 3)
End Sub
 
Upvote 0
Assuming the 010407 is 6 text characters and not a 5 digit number formatted to show the leading 0, then one formula approach would as shown below, with cell B1 formatted with the appropriate Date format.

Excel Workbook
AB
10104071/4/2007
Date




Edit: Or following on from HOTPEPPER's idea, a manual approach..
Data|Text to columns...|Next|Next|Date|Finish
Then format the cell/column to a different date format if required.

Edit again: Overlooked this though, oops. :oops:
i will be using it in code though.
 
Upvote 0
Also

=VALUE(TEXT(A1,"00\/00\/00"))

No problem if you don't have the leading "0".

EDIT:
Like Peter I also overlook the code part

DateValue (Format([a1], "00/00/00"))
 
Upvote 0
Hi Jon

The "\" inside the format string is an escape charater, it tells excel not to interpret the next character. Since "/" inside the format string has a special meaning, it's a date delimeter, if I would not use the "\/" it would mess up things up.

This way you get the string "01/04/06" out of the text function, that is then converted using the Value() function.

Remark: You could write the "/" between double quotes.
 
Upvote 0
Hi Jon

The "\" inside the format string is an escape charater, it tells excel not to interpret the next character. Since "/" inside the format string has a special meaning, it's a date delimeter, if I would not use the "\/" it would mess up things up.

This way you get the string "01/04/06" out of the text function, that is then converted using the Value() function.

Remark: You could write the "/" between double quotes.

Very nice! Thanks pgc01, I've added this to my favourites for future reference! :biggrin:

Jon
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,290
Members
449,149
Latest member
mwdbActuary

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