Conversión de UTC a EST

Un usuario Pregunto ✅

Daven

Hola,

Estoy buscando convertir la columna de fecha y hora UTC al horario de verano EST. ¿Cómo lo convierto en PowerBI?

Gracias por su ayuda de antemano

Daven

Para convertir lo que @mahoneypat publicó funciona, pero si está tratando de compensar el horario de verano de forma dinámica, consulte el siguiente código M.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDLCQAhDAV78Sxonv9axP7bWLNPMN4mDMYhc7oUBAFRmvNOJBTy8r8RnTpNJh8TdRo0iUzT94BIIeTzRBdAaBr5GF0A0FTyMZqGdNM2mwDkG7CZZuhQKEA2ZdWI+pQ1U9ae/7v5v9vTYNzTYNiyFG/Z5rU+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [dtDSTStart = _t, dtDSTEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"dtDSTStart", type date}, {"dtDSTEnd", type date}}),
    varCurrentDate = DateTime.Date(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-8)),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [dtDSTStart] < varCurrentDate and [dtDSTEnd] > varCurrentDate),
    varDSTOffset = Table.RowCount(#"Filtered Rows"),
    #"Last Refresh Date" = #table(
        type table
            [
                #"RefreshDate"=datetimezone
            ],
        {
            {DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-8 + varDSTOffset,0)}
        }
        )
in
    #"Last Refresh Date"

Si, en Power Query, selecciona el icono de engranaje junto a la Fuente, verá la tabla de horarios de activación / desactivación del horario de verano de EE. UU. Necesita cambiar mi -8 para PST a -5 para EST. Esto agregará o no agregará dinámicamente 1 hora para el horario de verano según sea necesario, según el calendario del sistema.

Si solo desea calcular el desplazamiento DST (1 o 0), elimine el último paso de longitud:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDLCQAhDAV78Sxonv9axP7bWLNPMN4mDMYhc7oUBAFRmvNOJBTy8r8RnTpNJh8TdRo0iUzT94BIIeTzRBdAaBr5GF0A0FTyMZqGdNM2mwDkG7CZZuhQKEA2ZdWI+pQ1U9ae/7v5v9vTYNzTYNiyFG/Z5rU+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [dtDSTStart = _t, dtDSTEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"dtDSTStart", type date}, {"dtDSTEnd", type date}}),
    varCurrentDate = DateTime.Date(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-8)),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [dtDSTStart] < varCurrentDate and [dtDSTEnd] > varCurrentDate),
    varDSTOffset = Table.RowCount(#"Filtered Rows")
in
    varDSTOffset

Luego, usando las fórmulas @mahoneypat enumeradas, puede usar algo como

=DateTimeZone.SwitchZone([UTC Date Column],-8 + varDSTOffset,0)

1) En Power Query, seleccione New Source, luego Blank Query
2) En la cinta de Inicio, seleccione el botón «Editor avanzado»
3) Elimina todo lo que ves, luego pega el código M que te he dado en ese cuadro.
4) Presione Listo
5) Consulte este artículo si necesita ayuda para usar este código M en su modelo.

Hola @Daven,

Verifique la referencia a continuación:

https://in satellitect.com/convert-utc-local-time-daylight-savings-support-power-bi/

Atentamente,
Kelly
¿Respondí tu pregunta? ¡Marque mi publicación como una solución!

Hola @Daven,

Verifique la referencia a continuación:

https://in satellitect.com/convert-utc-local-time-daylight-savings-support-power-bi/

Atentamente,
Kelly
¿Respondí tu pregunta? ¡Marque mi publicación como una solución!

Para convertir lo que @mahoneypat publicó funciona, pero si está tratando de compensar el horario de verano de forma dinámica, consulte el siguiente código M.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDLCQAhDAV78Sxonv9axP7bWLNPMN4mDMYhc7oUBAFRmvNOJBTy8r8RnTpNJh8TdRo0iUzT94BIIeTzRBdAaBr5GF0A0FTyMZqGdNM2mwDkG7CZZuhQKEA2ZdWI+pQ1U9ae/7v5v9vTYNzTYNiyFG/Z5rU+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [dtDSTStart = _t, dtDSTEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"dtDSTStart", type date}, {"dtDSTEnd", type date}}),
    varCurrentDate = DateTime.Date(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-8)),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [dtDSTStart] < varCurrentDate and [dtDSTEnd] > varCurrentDate),
    varDSTOffset = Table.RowCount(#"Filtered Rows"),
    #"Last Refresh Date" = #table(
        type table
            [
                #"RefreshDate"=datetimezone
            ],
        {
            {DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-8 + varDSTOffset,0)}
        }
        )
in
    #"Last Refresh Date"

Si, en Power Query, selecciona el icono de engranaje junto a la Fuente, verá la tabla de horarios de activación / desactivación del horario de verano de EE. UU. Necesita cambiar mi -8 para PST a -5 para EST. Esto agregará o no agregará dinámicamente 1 hora para el horario de verano según sea necesario, según el calendario del sistema.

Si solo desea calcular el desplazamiento DST (1 o 0), elimine el último paso de longitud:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZDLCQAhDAV78Sxonv9axP7bWLNPMN4mDMYhc7oUBAFRmvNOJBTy8r8RnTpNJh8TdRo0iUzT94BIIeTzRBdAaBr5GF0A0FTyMZqGdNM2mwDkG7CZZuhQKEA2ZdWI+pQ1U9ae/7v5v9vTYNzTYNiyFG/Z5rU+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [dtDSTStart = _t, dtDSTEnd = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"dtDSTStart", type date}, {"dtDSTEnd", type date}}),
    varCurrentDate = DateTime.Date(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),-8)),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [dtDSTStart] < varCurrentDate and [dtDSTEnd] > varCurrentDate),
    varDSTOffset = Table.RowCount(#"Filtered Rows")
in
    varDSTOffset

Luego, usando las fórmulas @mahoneypat enumeradas, puede usar algo como

=DateTimeZone.SwitchZone([UTC Date Column],-8 + varDSTOffset,0)

1) En Power Query, seleccione New Source, luego Blank Query
2) En la cinta de Inicio, seleccione el botón «Editor avanzado»
3) Elimina todo lo que ves, luego pega el código M que te he dado en ese cuadro.
4) Presione Listo
5) Consulte este artículo si necesita ayuda para usar este código M en su modelo.

En el editor de consultas, puede utilizar una de las funciones DateTimeZone como DateTimeZone.ToLocal o DateTimeZone.SwitchZone.

https://docs.microsoft.com/en-us/powerquery-m/datetimezone-zonehours

Si esto le funciona, márquelo como la solución. Las felicitaciones también son apreciadas. Por favor avíseme si no.

Saludos,

Palmadita

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *