Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Remove seconds from a timestamp field

Hi Team,

 

I am new to PowerBI and hence this question might be very simple but it would be very helpful if you help me with it.

 

I have a field in my table "A_Timestamp" and the value is 

01/02/18 12:08:25

I want to ignore the seconds and display the result as

01/02/18 12:08

How can this be achieved?

 

Thank you very much in advance.

 

Regards,

Ani

  • HI Anonymous

     

    You can use the formatting features in the toolbar as Anonymous suggested.

     

    Another option is to use the FORMAT function that allows you to control the format string.  To convert your date you would use FORMAT( <datevalue> , "dd/MM/YY hh:mm" )

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    If it is just for display purposes, you can select the individual column and go into the Modelling Tab on the top menu.  Under there is a Data format section whereby you can choose a format that does not display the seconds.

     

     

    If you are wanting to strip out the seconds for the purpose of data comparisons, you will need to perform an operation that will 'round' the seconds.  This will depend how the data is stored, but generally time is the decimal component of the Date/Time number value.  So 0 equals midnight and 1 the following midnight, with 0.5 being mid day.  This would mean that a single minute would be (1 / 24 / 60) or (1 / 1440)

    If you take the number you have, multiply it by 1440 and round to zero decimal places (integer), then divide that back by 1440 and store as a decimal, you will have rounded the number.

     

    Consider how you round, as you will move the time either up or down to the nearest second.  If you want to always round down, you need to use a "Floor" operation instead.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much Ross73312 for your assistance.

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft Employee

    HI Anonymous

     

    You can use the formatting features in the toolbar as Anonymous suggested.

     

    Another option is to use the FORMAT function that allows you to control the format string.  To convert your date you would use FORMAT( <datevalue> , "dd/MM/YY hh:mm" )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much Phil_Seamark. Thanks for your quick assistance.

      • Alirezam's avatar
        Alirezam
        Helper V

        Easily follow this:

        in quesry view: Add column > Forma> Trim> Parse

        This way you'll get rid of the seconds