Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Syndicate_Admin
Administrator
Administrator

ISO8601 - convertir a fecha/hora ya no funciona

Uso worldtimeapi

= Json.Document(Web.Contents("http://worldtimeapi.org/api/timezone/Europe/London"))

que se presenta en formato ISO8601.

2022-03-30T12:41:22.719641+01:00

Hasta esto, podía convertir a fecha / hora, pero ahora estoy recibiendo un error. ¿Se debe esto a que los relojes cambian en el Reino Unido?

DataFormat.Error: No pudimos analizar la entrada proporcionada como un valor DateTime.
Detalles:
2022-03-30T12:41:22.784125+01:00

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Creo que es la transformación automática de 'cualquier' tipo de datos a 'datetime' lo que no funciona.

Si edita la parte {"datetime",escriba datetime} para que sea {"datetime", escriba datetimezone}, eso debería funcionar sin errores.

A partir de ahí, puede cambiar el tipo a datetime, utilizando el > de interfaz (agregue el paso si se le da la opción, para que sea más obvio).

No estoy seguro de si solía funcionar o si ha habido un cambio en el código de Power Query, pero eso debería hacer que funcione.

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Creo que es la transformación automática de 'cualquier' tipo de datos a 'datetime' lo que no funciona.

Si edita la parte {"datetime",escriba datetime} para que sea {"datetime", escriba datetimezone}, eso debería funcionar sin errores.

A partir de ahí, puede cambiar el tipo a datetime, utilizando el > de interfaz (agregue el paso si se le da la opción, para que sea más obvio).

No estoy seguro de si solía funcionar o si ha habido un cambio en el código de Power Query, pero eso debería hacer que funcione.

¡Increíble!

Gracias. Modificaré el resto de mis informes que utilizan este método.

Syndicate_Admin
Administrator
Administrator

¿Puede publicar el código que cambia el tipo, por favor?

= Table.TransformColumnTypes(#"Converted to Table",{{"abbreviation", type text}, {"client_ip", type text}, {"datetime", type datetime}, {"day_of_week", Int64.Type}, {"day_of_year", Int64.Type}, {"dst", type logical}, {"dst_from", type any}, {"dst_offset", Int64.Type}, {"dst_until", type any}, {"raw_offset", Int64.Type}, {"timezone", type text}, {"unixtime", Int64.Type}, {"utc_datetime", type datetime}, {"utc_offset", type text}, {"week_number", Int64.Type}})

CÓDIGO COMPLETO

let
    Source = Json.Document(Web.Contents("http://worldtimeapi.org/api/timezone/Europe/London")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"abbreviation", type text}, {"client_ip", type text}, {"datetime", type datetime}, {"day_of_week", Int64.Type}, {"day_of_year", Int64.Type}, {"dst", type logical}, {"dst_from", type any}, {"dst_offset", Int64.Type}, {"dst_until", type any}, {"raw_offset", Int64.Type}, {"timezone", type text}, {"unixtime", Int64.Type}, {"utc_datetime", type datetime}, {"utc_offset", type text}, {"week_number", Int64.Type}})
in
    #"Changed Type"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.