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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
afinman
New Member

DateDiff and NOW do not work

I have an increasingly frustrated with PowerBI

 

I have many tables with DateTime values in from SQL Server. I want to do DateDiff functions on these in PowerBI comparing to NOW() so I can get Days/Hours/Minutes since these dates, but PowerBI just gets upset and errors:

 

I have had to resort to creating views in the database to do this which seems silly. I have been playing this morning and note that when I do StartedMinutesAgo = DATEDIFF(NOW(), ProbeRun[StartTime], MINUTE) it fails, but If I do StartedMinutesAgo = DATEDIFF("2017-01-01", ProbeRun[StartTime], MINUTE) it works fine which presumably means it is unhappy with the output of NOW() and TODAY() rather than the data in my database tables.

 

The error is


The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.. The exception was raised by the IDataReader interface.

 

HELP!

 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@afinman,

 

As shown in the error message, the data type is nvarchar and can not be automatically converted to datetime for the current date/time settings. You'll need to perform explicit conversion accordingly.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@afinman,

 

As shown in the error message, the data type is nvarchar and can not be automatically converted to datetime for the current date/time settings. You'll need to perform explicit conversion accordingly.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
afinman
New Member

I have an increasingly frustrated with PowerBI

 

I have many tables with DateTime values in from SQL Server. I want to do DateDiff functions on these in PowerBI comparing to NOW() so I can get Days/Hours/Minutes since these dates, but PowerBI just gets upset and errors:

 

I have had to resort to creating views in the database to do this which seems silly. I have been playing this morning and note that when I do StartedMinutesAgo = DATEDIFF(NOW(), ProbeRun[StartTime], MINUTE) it fails, but If I do StartedMinutesAgo = DATEDIFF("2017-01-01", ProbeRun[StartTime], MINUTE) it works fine which presumably means it is unhappy with the output of NOW() and TODAY() rather than the data in my database tables.

 

The error is


The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.. The exception was raised by the IDataReader interface.

 

HELP!

 

I have just found that the relative search for dates/times errors with the same issue.

Am wonderinf if this is a locale issue with PowerBI and SQL...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors