Forum Discussion

Christian2320's avatar
Christian2320
New Member
1 year ago
Solved

text to time

Hello! My first post here, thanks for reading! I have a PostgreSQL database with a table, which cointains schedule information of public transport. The hours of time of departure can be more than 2...
  • Hakuna_matata's avatar
    Hakuna_matata
    1 year ago

    I see you mentioned using Direct query, I would suggest using Native query

    1. Creating your model with the property "Direct Query Mode: Off".

    -Then, If you create your own query, using Sql.Database()

    let
        database name
        Source = Sql.Database("MyConnection", "DATABASE", [Query="
            SELECT
                departure_time,
                -- Convert departure_time (HH:MM) to total minutes
                CAST(split_part(departure_time, ':', 1) AS INTEGER) * 60 + CAST(split_part(departure_time, ':', 2) AS INTEGER) AS total_minutes
            FROM
                transport_schedule
        "]),
        // if needed
        CleanedData = Table.SelectRows(Source, each [total_minutes] > 0)  // Example of filtering
    in
        CleanedData

     -Once transformation is done you may switch to "Direct Query Mode: On"

    That might work!