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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
suji
Advocate I
Advocate I

validate current timestamp between given start and end date times

Hi,

 

I have to validate current timestamp between given start and end date times on Power BI Desktop.

 

 

Thanks & Regards,

Suresh Peddirsi,

1 ACCEPTED SOLUTION
Baskar
Resident Rockstar
Resident Rockstar

Don't worry dude we have another one way

 

Time Difference =
var Start_Date = NOW()  -- Replace Now() with start_date 
var end_Date = NOW()    -- Replace Now() with end_date 

var Start_time = FORMAT(Start_Date,"HH:mm:ss")
var End_time = FORMAT(end_Date,"HH:mm:ss")

return FORMAT( TIME(LEFT(Start_time,2) ,MID(Start_time,4,2),RIGHT(Start_time,2)) -
TIME(LEFT(End_time,2) ,MID(End_time,4,2),RIGHT(End_time,2)) , "HH:mm:ss"
)

 

 

I hope it will give u the time difference dude..

 

 

let me know any further doubts . cheers 

 

View solution in original post

5 REPLIES 5
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

Hi @suji,

What is the format of your timestamp column? Do you set the Data Type of the timestamp column to Date/Time? If you have changed its data type to Date/Time, you are able to directly check if current timestamp is between given start date and end date using formulas as follows.

Column = if(Table3[Timestamp]-Table3[Start Date]>=0 && Table3[End Date]-Table3[Timestamp]>=0,1,0)
MinColumn = if((24*60*(Table3[Timestamp]-Table3[Start Date])>=0) && (24*60*(Table3[End Date]-Table3[Timestamp]))>=0,1,0)
1.png

You can review this similar blog about how to calculate difference between two dates in DAX.

If the above example doesn’t return your expected result, please help to post sample data of your timestamp column and tell us what is the data type of this column.

Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Baskar
Resident Rockstar
Resident Rockstar

Datediff (Startdate,Enddate,Day)

 

so use DateDiff function it will help u

Hi Baskar,

 

Thanks for your quick response. Datediff will work for date compare. but my issue is Date with timestamp.

 

I have to check current timestamp is between given start date and end date.

 

Thanks & Regards,

Suresh Peddirsi

Baskar
Resident Rockstar
Resident Rockstar

Don't worry dude we have another one way

 

Time Difference =
var Start_Date = NOW()  -- Replace Now() with start_date 
var end_Date = NOW()    -- Replace Now() with end_date 

var Start_time = FORMAT(Start_Date,"HH:mm:ss")
var End_time = FORMAT(end_Date,"HH:mm:ss")

return FORMAT( TIME(LEFT(Start_time,2) ,MID(Start_time,4,2),RIGHT(Start_time,2)) -
TIME(LEFT(End_time,2) ,MID(End_time,4,2),RIGHT(End_time,2)) , "HH:mm:ss"
)

 

 

I hope it will give u the time difference dude..

 

 

let me know any further doubts . cheers 

 

Thanks Baskar

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 MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.