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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
MarshallWilley
Regular Visitor

Dynamic parameter for datetime is 12 hours off

Hello, I'm having a problem with a report page that uses a dynamic parameter for the date from the selection on a slicer to change the SQL query. It appears to work except that the resulting data seems to start at 12pm instead of 12am as seen below. And I can confirm in the database that there are entries before 12pm.

MarshallWilley_0-1752264571925.png

The parameter passes successfully to the database query using the Power Query code snippet below pasted from the Advanced Editor. The 2nd usage of it defines an endpoint 24 hours later, which appears to work as intended (endpoints stop at 12pm next day), but again shifted the same 12 hours.

Where Test_History.Entry_On Between '" & DateTime.ToText(StartTimeParameter,"yyyy-MM-dd hh:mm:ss") & "' And '" & DateTime.ToText(Date.AddDays(StartTimeParameter,1),"yyyy-MM-dd hh:mm:ss") & "'

I have the parameter defined like this...

MarshallWilley_1-1752265015032.png

And it is bound to a date table like this...

MarshallWilley_2-1752265120824.png

I've tried changing around the format options for each of these linkages, to no avail. I'm not sure what could be adding/changing the 12 hours. Any ideas?

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @MarshallWilley ,
In your Power Query code, change the datetime format string from "hh:mm:ss" to "HH:mm:ss" to force 24-hour time (midnight), and always convert your parameter to midnight with this:

DateTime.ToText(DateTime.From(Date.From(StartTimeParameter)), "yyyy-MM-dd HH:mm:ss")

 This will ensure your parameter always passes 00:00:00 (midnight) and fix the 12-hour offset problem.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

3 REPLIES 3
rohit1991
Super User
Super User

Hi @MarshallWilley ,
In your Power Query code, change the datetime format string from "hh:mm:ss" to "HH:mm:ss" to force 24-hour time (midnight), and always convert your parameter to midnight with this:

DateTime.ToText(DateTime.From(Date.From(StartTimeParameter)), "yyyy-MM-dd HH:mm:ss")

 This will ensure your parameter always passes 00:00:00 (midnight) and fix the 12-hour offset problem.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Thanks for your help, that worked!

danextian
Super User
Super User

Hi @MarshallWilley 

Your're using TODAY in your calendar formula which value depends on where it is being evaluated. In Desktop, it is based on your device's timezone. The service though uses UTC so intead of using TODAY directly, get the current UTC datetime first and add to or subtract several hours from it based on your UTC offset. Try:

StartDateTAble =
VAR _TZOffset = 8 --for UTC+8
RETURN
    CALENDAR ( DATE ( 2022, 12, 27 ), INT ( UTCNOW () + DIVIDE ( _TZOffset, 24 ) ) )

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.