Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Date time comparison with NOW() function

Hello Everyone, I have an issue with comparing two datetime values. The goal is to mark all the rows of data that are within 6:00:00 AM 3 days ago and 6:00:00 AM today:   As you may see upp...
  • johnt75's avatar
    3 years ago

    I think the problem is that FORMAT is returning a string, so the IF statement is comparing 2 string values. Try

    Within last 3 days =
    VAR Is3Day =
        TODAY () - 3
            + TIME ( 6, 0, 0 )
    VAR IsToday =
        TODAY () + TIME ( 6, 0, 0 )
    RETURN
        IF ( 'Table'[DateTime] >= Is3Day && 'Table'[DateTime] <= IsToday, "Yes", "No" )