Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Extract year from date data

I've been trying to use Date.Year to extract yyyy from mm/dd/yyyy, for a few days now. The best thought I have is to convert the date to text and take the last four characters, but I believe there's ...
  • wdx223_Daniel's avatar
    wdx223_Daniel
    4 years ago

    the first parameter of this function should be text, not a date value.

    if [order date] is date type,try Text.AfterDelimiter(Text.From([ORDER DATE]),"/",{0,1})

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    If the column type is Date, please directly go to Add Column tab--> Date-->Year to extract :

     

     

    If the column type is Text, then go to Add Column tab--> Extract --> Last characters:

     

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

  • Anonymous's avatar
    Anonymous
    4 years ago

    It knows how to parse dates using the rules of the system's culture.

     

    = Table.TransformColumnTypes(Source,{{"Text", type date}}, "en-US")
    // verses
    = Table.TransformColumnTypes(Source,{{"Text", type date}}, "en-GB")
    // or
    = Table.TransformColumnTypes(Source,{{"Text", type date}}, "fr")
    
    // your default is
    = Culture.Current