Forum Discussion

Prasanthke's avatar
Prasanthke
Frequent Visitor
1 year ago
Solved

Date/Time

how to convert the date/time columns in text data type to data and time columns seperately

 

10-10-2017 21:25

 

  • PQ should recognise such a text and be able to set the data type to Date/Time.

     

    Then, on the Add Column Ribbon and choose Date, Date Only in the From Date & Time group. Repeat that step for the time portion (Time, Time Only).

     

     

     

     

  • Hi Prasanthke , Just replace your source query and DateTimeColumn in the below M Code

    let
        Source = YourTable,
        DateColumn = Table.AddColumn(Source, "Date", each Date.From(Text.From([DateTimeColumn]))),
        TimeColumn = Table.AddColumn(DateColumn, "Time", each Time.From(Text.From([DateTimeColumn])))
    in
        TimeColumn

     

    Thanks,

    Jai Rathinavel | LinkedIn

  • Hi Prasanthke ,

    Thank you  for reaching out to the Microsoft fabric community forum.

     

    I would also take a moment to thank Jai-Rathinavel and Riny_vE  for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.


    please gothorugh the below official Documentation hope this resolve your Issue.
    https://learn.microsoft.com/en-us/powerquery-m/date-fromtext?

    If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

    Best Regards,
    Harshitha.
    Community Support Team

7 Replies

  • PQ should recognise such a text and be able to set the data type to Date/Time.

     

    Then, on the Add Column Ribbon and choose Date, Date Only in the From Date & Time group. Repeat that step for the time portion (Time, Time Only).

     

     

     

     

  • Hi Prasanthke , Just replace your source query and DateTimeColumn in the below M Code

    let
        Source = YourTable,
        DateColumn = Table.AddColumn(Source, "Date", each Date.From(Text.From([DateTimeColumn]))),
        TimeColumn = Table.AddColumn(DateColumn, "Time", each Time.From(Text.From([DateTimeColumn])))
    in
        TimeColumn

     

    Thanks,

    Jai Rathinavel | LinkedIn

  • v-hjannapu's avatar
    v-hjannapu
    Community Support

    Hi Prasanthke ,

    Thank you  for reaching out to the Microsoft fabric community forum.

     

    I would also take a moment to thank Jai-Rathinavel and Riny_vE  for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.


    please gothorugh the below official Documentation hope this resolve your Issue.
    https://learn.microsoft.com/en-us/powerquery-m/date-fromtext?

    If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

    Best Regards,
    Harshitha.
    Community Support Team

    • v-hjannapu's avatar
      v-hjannapu
      Community Support

      Hi Prasanthke,

      Just wanted to check if you had the opportunity to review the suggestion provided?

      If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.

       

      Thank You.

      Harshitha.

      Community Support Team.

      • v-hjannapu's avatar
        v-hjannapu
        Community Support

        Hi Prasanthke,

        I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please Accept it as a solution so that other community members can find it easily.

        Thank You.

        Harshitha.

        Community Support Team.

  • USe the following code

     

    let
        Source = YourTable,
        ChangedType = Table.TransformColumnTypes(Source, {{"DateTimeText", type datetime}}),
        AddDate = Table.AddColumn(ChangedType, "DateOnly", each DateTime.Date([DateTimeText]), type date),
        AddTime = Table.AddColumn(AddDate, "TimeOnly", each DateTime.Time([DateTimeText]), type time)
    in
        AddTime