Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Date format

I need to format school year, i.e. 2020-21, that I can reference for year-to-year calculations.
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous,

    Sure, your values aren't the regular date types, it seems like you stored the start and end years into one field, right?

    If this is a case, I'd like to suggest you add two calculated columns to extract the start part and end part from your raw field then you can set conditions based on new fields.

    Calculate columns:

    Start = 
    DATE ( VALUE ( LEFT ( [Year], 4 ) ), 12, 31 )
    
    End = 
    DATE ( VALUE ( LEFT ( [Start], 2 ) & RIGHT ( [Year], 2 ) ), 12, 31 )
    

    Notice: the right part 12 and 31 is the default value I used to complete the date function because your raw value did not exist the month and day levels.

    Regards,

    Xiaoxin Sheng

  • PhilipTreacy's avatar
    5 years ago

    Anonymous It has a date or datetime data type depending on whether you are using Power Query or DAX, but not sure what youo mean by date format for date ranges - usually when you want to work with elapsed time or durations you have a separate start and end date/time.

    Phil


    If I answered your question please mark my post as the solution.
    If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.