Forum Discussion

badgeming's avatar
badgeming
Frequent Visitor
8 years ago
Solved

MySQL - how do I add another column to return the integer of the date

Hi, I have a DateCreated column coming from a MySQL dataset where the values are in dd/mm/yy hh:mm:ss.  I want to create another column that is just dd/mm/yy format without the hh:mm:ss bit (i.e an integer of my DateCreated column).  I have tried going via Edit Queries, selecting the DateCreated column and under add column, date, selecting Date only.  This adds another column with the date only but my whole report disappears and I can't build it from scratch.  Any ideas?

  • So, in DAX, you could create a new column with this formula:

     

    Column = INT([Date])
    
    

    Then, set this to "Date" as a Data Type in the Modeling ribbon.

     

    This works because DAX Date/Time is a numeric data type where the integer portion is the number of days from December 30th, 1899 and the decimal portion is the time component.

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    So, in DAX, you could create a new column with this formula:

     

    Column = INT([Date])
    
    

    Then, set this to "Date" as a Data Type in the Modeling ribbon.

     

    This works because DAX Date/Time is a numeric data type where the integer portion is the number of days from December 30th, 1899 and the decimal portion is the time component.

    • badgeming's avatar
      badgeming
      Frequent Visitor

      Excellent, thank you