Forum Discussion

harishuppala2's avatar
harishuppala2
Frequent Visitor
6 years ago

How to Get Month and time from Datetime Field

Hi, 

Can anyone help me to achive this 

I am trying to get Month name and the time from datetime feild 

 

example : 

Datetime formate : 6/27/2019 11:00:00 AM 
Formate i am looking for  : Jan 27 11:00 AM

4 Replies

  • kentyler's avatar
    kentyler
    Solution Sage

    I think if you use FORMAT() you can build a custom string however you want. Here's the link https://docs.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

     

    I'm a personal Power Bi Trainer I learn something every time I answer a question

    The Golden Rules for Power BI

    1. Use a Calendar table. A custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. https://www.youtube.com/watch?v=FxiAYGbCfAQ
    2. Build your data model as a Star Schema. Creating a star schema in Power BI is the best practice to improve performance and more importantly, to ensure accurate results! https://www.youtube.com/watch?v=1Kilya6aUQw
    3. Use a small set up sample data when developing. When building your measures and calculated columns always use a small amount of sample data so that it will be easier to confirm that you are getting the right numbers.
    4. Store all your intermediate calculations in VARs when you’re writing measures. You can return these intermediate VARs instead of your final result  to check on your steps along the way.
    • harishuppala2's avatar
      harishuppala2
      Frequent Visitor

      kentyler  thanks for the Quick reply 

      i got the result formated as i need but the result is in Text date type and when i change the type to datetime its converting back to the format 

      can you suggest how to solve this.

       

      dax i used : 

      = FORMAT([roundedhour],"mmm d h:ss AM/PM")
       
      • kentyler's avatar
        kentyler
        Solution Sage

        It is possible some ways of writing a date as text cannot be automatically converted back to being dates, you can refer to the original field to get the value as a date as long as its in the table, it does not have to be on the visual.