-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_DateTime_ToOData.pq
More file actions
51 lines (45 loc) · 1.42 KB
/
test_DateTime_ToOData.pq
File metadata and controls
51 lines (45 loc) · 1.42 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
let
/*
Description
Convert PowerQuery `datetime` and `datetimezone` to a OData format
OData primatives: https://www.odata.org/documentation/odata-version-2-0/json-format/
Example:
9/8/2020 2:01:50 PM DateTime Local
9/8/2020 2:01:50 PM -05:00 DateTimeZone Local
9/8/2020 7:23:18 PM +00:00 DateTimeZone Utc
Output:
datetime'2020-09-08T14:01:49'
datetimeoffset'2020-09-08T14:01:49'
datetimeoffset'2020-09-08T19:23:17'
*/
Source = #table(
type table[Label = text, Format = text, Example = text, Input = any],
{
// "there is no 'date' primative type?",
{
"DT Fixed local",
"datetime'yyyy-mm-ddThh:mm[:ss[.fffffff]]",
"datetime'2000-12-12T12:00'",
DateTime.FixedLocalNow()
},
{
"DTZ Fixed Local",
"..",
"datetimeoffset'2002-10-10T17:00:00Z'",
DateTimeZone.FixedLocalNow()
},
{
"DTZ Fixed UTC",
"..",
"datetimeoffset'2002-10-10T17:00:00Z'",
DateTimeZone.FixedUtcNow()
}
}),
colUsingFunction = Table.AddColumn(
Source,
"Results",
each DateTime_ToOData( [Input] ),
type text ),
Final = colUsingFunction
in
Final