Forum Discussion
Date TIme Change
Good morning and Happy New Year
I have a data set that is in a ddmmyy time format but text which is loading from a csv.
I am trying to convert this from UTC to local time +10
However I am getting errors no matter which way I try
I tried splitting then converting to date and time and then remerging.
= DateTimeZone.SwitchZone(DateTimeZone.From([YourDateTimeColumn]), 10)
Any helpers? This above gave me DDMMYY, Time +10 but not actually converting time?
- Read in the CSV document.
- Convert column data type to datetime using locale equals english-us.
- Add custom column for finish formula: [Start] + #duration(0,10,0,0)
- See if that gives you what you want
8 Replies
- ronrsnfldSuper User
Several problems
- Your date is in the form of a datetime.
- The DateTimeZone.SwitchZone function requires the first argument be a DateTimeZone, not a DateTime
- Your data column is Text.
- You need to set the data type as DateTime to do any functions
Leaving it as DateTime, the following code will add 10 hours:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTSNzTTNzIwMlEwMrAyNrAyMFCK1YGIW8DFTUzB4rEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Start = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Start", type datetime}}), #"Convert to Local" = Table.AddColumn(#"Changed Type","Finish", each [Start] + #duration(0,10,0,0), type datetime) in #"Convert to Local"Note that to add hours to a datetime is done by adding a duration.
- Babycakes_00Helper I
I have converted to this so far
- ronrsnfldSuper User
I'm afraid I have no idea what you're doing or how it relates to the code I provided. Please try to clarify.
Providing a better description of exactly what you want for output as well as the code that you are using from the advanced editor might be helpful.
- Your date is in the form of a datetime.