Forum Discussion
Syntax error in custom function to covert UTC to Central Time
- 1 year ago
The error messages often point to something other than what they specifically indicate.
Examining the code window can give you some hints.
For example, there is no `mod` operator in PQ and you will see that it has a wavy red underline in the editor:
You need to use the `Number.Mod` function.
Also, if your computer itself is set to Central Time, there is a much simpler method to convert to local time (or to the local time of whatever a computer is set to (and it will take DST into account):
// Function to convert UTC to Local Time) (ConvertUTCtoLT as datetime) => let addTZ = DateTime.AddZone(ConvertUTCtoLT,0), toLocal = DateTimeZone.ToLocal(addTZ), localDateTime=DateTime.From(toLocal) in localDateTime
The error messages often point to something other than what they specifically indicate.
Examining the code window can give you some hints.
For example, there is no `mod` operator in PQ and you will see that it has a wavy red underline in the editor:
You need to use the `Number.Mod` function.
Also, if your computer itself is set to Central Time, there is a much simpler method to convert to local time (or to the local time of whatever a computer is set to (and it will take DST into account):
// Function to convert UTC to Local Time)
(ConvertUTCtoLT as datetime) =>
let
addTZ = DateTime.AddZone(ConvertUTCtoLT,0),
toLocal = DateTimeZone.ToLocal(addTZ),
localDateTime=DateTime.From(toLocal)
in
localDateTime