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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
MarkTeviotdale
Frequent Visitor

TicksToDateTime Not Working

We are currently connected to Cosmos DB Databases with Table API using a SQL connector in PowerBI

 

Everything has been working just fine for a number of years now,  but overnight we ran into an issue with a TicksToDateTime conversion.

 

Here is a simplified example of query we are using

 

SELECT {
"PartitionKey": c["$pk"],
"RowKey": c["$id"],
"CreatedTStamp": TicksToDateTime(StringToNumber(c["CreatedTStamp"]["$v"]) - 621355968000070000),
"Animal": c["Animal"]["$v"]
}
AS Entities
FROM EventData c
WHERE c["$pk"] = "WeightRecord"

 

The "CreatedTStamp" Field no longer returns a value.

 

"CreatedTStamp": TicksToDateTime(StringToNumber(c["CreatedTStamp"]["$v"]) - 621355968000070000),

 

As mentioned this has been working for years,  We can strip the "CreatedTStamp" field request down to component parts and return the correct values,  however the last step in the request TicksToDateTime has ceased to work.  

 

The Table API stores the DateTime as Ticks from 1 AD at its most base level,  we are using this formula to covert it into a usable datetime at our end.

 

Can you please advise what has change overnight,  if we were informed of the change,  if there is a possibility the change is reverted and/or if you have any advise on how to proceed.

1 ACCEPTED SOLUTION

Thanks @v-shex-msft for your message. 

 

We have a ticket in with Azure and the issue appears to be on the Azure Cosmos side, the current workaround at the moment is to add a ltrim example below: 

 

add ltrim for leading zeros

SELECT TicksToDateTime(StringToNumber(ltrim("00638435451214931790", "0")) - 621355968000070000)

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @MarkTeviotdale ,

Can you please share some more detail information about this issue and error messages? They should help us clarify your scenario and test to troubleshoot.

How to Get Your Question Answered Quickly  

In addition, have you check on the data source to confirm if this issue only appeared on power bi side?
If that is the case, I'd like to suggest you check on the recently updated if anything change applied to the api interface.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks @v-shex-msft for your message. 

 

We have a ticket in with Azure and the issue appears to be on the Azure Cosmos side, the current workaround at the moment is to add a ltrim example below: 

 

add ltrim for leading zeros

SELECT TicksToDateTime(StringToNumber(ltrim("00638435451214931790", "0")) - 621355968000070000)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors