Forum Discussion

Rnaval's avatar
Rnaval
Post Partisan
5 months ago
Solved

Need help with a date \ time field

How do I convert a field with the following date/time value to a date and time field? This is March 11, 2026 and time is 1:36 pm

 

2026/3/11 13:36 EST (UTC -04:00)

  • Hi Rnaval 

    I would suggest first extracting the text before the 2nd space character (assuming timezone can be discarded), then using DateTime.ToText with a format string to convert to a datetime value.

     

    Here is a sample query to illustrate:

    let
      Source = #table(
        type table [DateTime Text = text],
        {
          {"2026/3/11 13:36 EST (UTC -04:00)"},
          {"2026/4/01 09:16 EST (UTC -04:00)"},
          {"2026/12/31 17:26 EST (UTC -04:00)"}
        }
      ),
      #"Add DateTime" = Table.AddColumn(
        Source,
        "DateTime",
        each DateTime.FromText(
          Text.BeforeDelimiter([DateTime Text], " ", 1),
          [Format = "yyyy/M/dd HH:mm"]
        ),
        type datetime
      )
    in
      #"Add DateTime"

    You may want to use Table.TransformColumns rather than Table.AddColumn.

     

    Is this what you're looking for?

1 Reply

  • Hi Rnaval 

    I would suggest first extracting the text before the 2nd space character (assuming timezone can be discarded), then using DateTime.ToText with a format string to convert to a datetime value.

     

    Here is a sample query to illustrate:

    let
      Source = #table(
        type table [DateTime Text = text],
        {
          {"2026/3/11 13:36 EST (UTC -04:00)"},
          {"2026/4/01 09:16 EST (UTC -04:00)"},
          {"2026/12/31 17:26 EST (UTC -04:00)"}
        }
      ),
      #"Add DateTime" = Table.AddColumn(
        Source,
        "DateTime",
        each DateTime.FromText(
          Text.BeforeDelimiter([DateTime Text], " ", 1),
          [Format = "yyyy/M/dd HH:mm"]
        ),
        type datetime
      )
    in
      #"Add DateTime"

    You may want to use Table.TransformColumns rather than Table.AddColumn.

     

    Is this what you're looking for?