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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
tdisalvo
New Member

I need to subtract one day if the time is between 12AM and 2AM

I have a Time field =IC_HistoryProducts[Time]

And a Date field= IC_HistoryProducts[TransactionDate]

 

What I need is to subtract 1 day from the date field if the time field is between 12AM~2AM

 

This is driving me nuts and could use some help

1 ACCEPTED SOLUTION
jthomson
Solution Sage
Solution Sage

What does this do:

 

newcolumn = if(hour(IC_HistoryProducts[Time])<2, previousday(IC_HistoryProducts[TransactionDate]),IC_HistoryProducts[TransactionDate])

View solution in original post

2 REPLIES 2
Pulkit
Resolver I
Resolver I

Hi,

 

Try

new column = IF([Timecolumn]>12:00AM,IF([Timecolumn]<2:00AM,DATEADD([datecolumn],-1,date),[datecolumn])

 

I am not sure if this is it so let me know if it works.

jthomson
Solution Sage
Solution Sage

What does this do:

 

newcolumn = if(hour(IC_HistoryProducts[Time])<2, previousday(IC_HistoryProducts[TransactionDate]),IC_HistoryProducts[TransactionDate])

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.