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
Anonymous
Not applicable

DataFormat error while trying to convert to DateTimeZone

Hi,

 

I'm trying to get data from Azure Cosmos DB with mongoDB API as a data source.

 

One of the fileds in the json record is 'time' with BSON Date type as mongoDB treats date types.

 

The Date value of the record in mongoDB looks like this:

 

https://imgur.com/0MMdaMV

 

which is:

"time" : ISODate("2019-03-01T05:41:39.000Z")

 

Atfter clicking on 'Refresh Preview' and expanding my document I'm getting a record value in 'time' field:

 

https://imgur.com/oYUkUEU

 

Containing this value:

 

https://imgur.com/IZJrJHt

 

 

When trying to refresh power bi I'm getting this error:

 

DataFormat.Error: We couldn't convert to DateTimeZone.
Details:
1.55142E+12

 

I tried to change the type for this column to any of these types Date/DateTime/DateTimeZone and it didn't work.

 

Can some help me with getting this value formated as DateTime / DateTimeZone type?

 

Thanks.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Maggie ,

 

The value I got is a BSON Date which is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). 

 

I managed to overcome this failure by adding a custom column with this calculation:

 

Table.AddColumn(#"Expanded time", "time", each #datetime(1970,1,1,0,0,0)+#duration(0,0,0,[#"$date"]/1000))

 

worked fine.

 

Thanks.

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

The final result (1.55142E+12) shows when you click on the "Record" field?

 

Best Regards

Maggie

 

Anonymous
Not applicable

Hi @Maggie ,

 

The value I got is a BSON Date which is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). 

 

I managed to overcome this failure by adding a custom column with this calculation:

 

Table.AddColumn(#"Expanded time", "time", each #datetime(1970,1,1,0,0,0)+#duration(0,0,0,[#"$date"]/1000))

 

worked fine.

 

Thanks.

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.