Forum Discussion
How to add hours to DateTime data?
- 9 years ago
You can add a duration to a datetime field, e.g. if your fieldname is "DateTime":
[DateTime] + #duration(0,10,0,0))
The arguments of#duration are days, hours, minutes, seconds.
Sorry, i write Duration here, but i tried with duration as follows:
StartDate = (adx_events[adx_releasedate] + #duration(0,10,0,0))
i get this error on powerbi query editor:
The following syntax error occurred during parsing: Invalid token, Line 1, Offset 32, #.
In the code below I copied your line without any modification and it works fine.
let
Source = {40000..40001},
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type date}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Column1", "adx_releasedate"}}),
adx_events = #"Renamed Columns"{0},
StartDate = (adx_events[adx_releasedate] + #duration(0,10,0,0))
in
StartDate
You can copy/paste this code into your query editor and see for yourself.
- quinncallan9 years agoNew Member
Hi
How do you add 10hrs to all dates in the list instead of just one?
- MarcelBeug9 years ago
Community Champion
Please don't hijack other topics for your own question, but start a new topic instead.
And don';t forget to react to replies you get, maybe give kudos, mark replies as answer, which you still have to do for your for your first and only topic so far, raised in April 2016.
- quinncallan9 years agoNew Member
My apologies, i believed my question was still on topic, asking a question about your answer and would enhanse the existing thread
- rohit018 years agoFrequent Visitor
Thansk a lot, your solution worked magically for my issue as well :)
- ErancO3 years agoFrequent Visitor
this works!