-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfxTextToDateTime.pq
More file actions
28 lines (26 loc) · 884 Bytes
/
Copy pathfxTextToDateTime.pq
File metadata and controls
28 lines (26 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// transform text "2024-10-15 19-00-24" to datetime "15-Oct-24 7:00:24 PM"
(tbl as table, columnName as text) as table =>
let
// Step 1: Replace the first dash in the time portion with a colon (at position 14)
ReplaceFirstDash = Table.TransformColumns(
tbl,
{
{columnName, each Text.ReplaceRange(_, 13, 1, ":"), type text}
}
),
// Step 2: Replace the second dash in the time portion with a colon (at position 16)
ReplaceSecondDash = Table.TransformColumns(
ReplaceFirstDash,
{
{columnName, each Text.ReplaceRange(_, 16, 1, ":"), type text}
}
),
// Step 3: Convert the final result to DateTime
FinalConversion = Table.TransformColumns(
ReplaceSecondDash,
{
{columnName, each DateTime.FromText(_), type datetime}
}
)
in
FinalConversion