Forum Discussion

michaelu1's avatar
michaelu1
Advocate II
3 years ago

Max date without time

I'm trying to calculate the most recent note based on a users note history.  Part of that involves making sure that the date of the note ('Note Detail'[LASTDATE]) is the same date as the call ('Call History'[Date]), both columns are data type "date" not date/time.


The issue that I'm having is that when I calculate the MAX of a date I get a timestamp even though that column has a data type of date. I got around it by comparing the year/month/day - highlighted red.

 

Is there a better way to do this?

Note Text =
VAR _NameID = MAX('Call History'[NameID])
VAR _Date = MAX('Call History'[Date])
VAR _UName = MAX('Call History'[Name2])
VAR _Text =
CALCULATE(
    MAX('Note Detail'[NOTETEXT]),
        'Note Detail'[NAMEID]=_NameID,
        MONTH('Note Detail'[LASTDATE])=MONTH(_Date) && YEAR('Note Detail'[LASTDATE]) = YEAR(_Date) && DAY('Note Detail'[LASTDATE])=DAY(_Date),
        'Note Detail'[User Name]=_UName
)

4 Replies

  • I just realized that I had this set up as a date type in the data view, not in the Query Editor. I switched the type there and that solved my problem.

    However, is there a to keep the time and still compare just the date without having to jump through these hoops?

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Super User

      Hi,

      In the Query Editor, you may create another column which extract the Date from the Date/time column.

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, michaelu1 

     

    Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • michaelu1's avatar
      michaelu1
      Advocate II

      I don't have a sample data set, but I can try to get one one if needed. 

       

      Very simply, if I have a date equaling 3/3/2023 10:58:23 AM and my filter context is set to 3/3/23, how can I get MAX(date) to equal my date? The issue being that MAX automatically adds on 12:00:00 AM and now they are no longer equal.