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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ovetteabejuela
Impactful Individual
Impactful Individual

Power Query | In between two times

Hi,

 

I think this is a very simple question to answer (probably why I can't find anything on the web) so I'm asking:

 

I want to check if a DateTime is in between 2 DateTimes

 

if DateTime(C) >= DateTime(A) or DateTime(C) <= DateTime(B) then 1 or 0

 

How do you do that in Power Query?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @ovetteabejuela,

 

You can add custom column in power query with if statement.

 

Sample:

    #"Added Custom" = Table.AddColumn(#"Previous step", "Custom", each if [C] >= [A] or [C] <= [B] then 1 else 0)

 

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @ovetteabejuela,

 

You can add custom column in power query with if statement.

 

Sample:

    #"Added Custom" = Table.AddColumn(#"Previous step", "Custom", each if [C] >= [A] or [C] <= [B] then 1 else 0)

 

Regards,

Xiaoxin Sheng

edhans
Super User
Super User

If they are in different columns, just reference the columns. If not, and you want to directly references the datetime, use the #datetime() function.

 

There is also a #date() function that is just #date(y,m,d)



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.