Excel Power Query

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have a table column that has a Text value in it "21.03.10". I want to create a new column that uses this as a Date. I need that new Date column to be an actual date not text Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Output = Table.AddColumn(Source, "Date", each 
        #date(Number.FromText("20" & Text.Range([TextDate],0,2)), Number.FromText(Text.Range([TextDate],3,2)),Number.FromText(Text.Range([TextDate],6,2)))),
    Type = Table.TransformColumnTypes(Output,{{"Date", type date}})
in
    Type

Book2
ABCD
1TextDateTextDateDate
221.03.1021.03.103/10/2021
320.04.1220.04.124/12/2020
419.12.0819.12.0812/8/2019
Sheet5
 
Upvote 0
Solution
Thank you. That did exactly what I needed. Very much appreciated!
 
Upvote 0
You could also try:

Date.FromText([TextDate], "en-GB")
 
Upvote 0
You could also try:

Date.FromText([TextDate], "en-GB")
When I test that it swaps the dd and yy. But will work if the century is prepended to the TextDate. For the example above using the Date.FromText approach:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Output = Table.AddColumn(Source, "Date", each Date.FromText("20" & [TextDate]))
in
    Output
 
Upvote 0
I interpreted 21.03.10 as 21 Mar 2010 :)
 
Upvote 0

Forum statistics

Threads
1,223,693
Messages
6,173,877
Members
452,536
Latest member
Chiz511

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