1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Extracting valid timestamps in SQL

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 28, 2024 às 15:43.

  1. Stack

    Stack Membro Participativo

    I am working with Netezza sql. I have a table (my_table). For col_1, I only want to extract rows that are in the following format: 2020-01-01 12:00:00 and col_2 is only numbers

    I am trying to do this with regexp_extract:

    SELECT *
    FROM my_table
    WHERE regexp_extract(col_1,
    '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$')
    IS NOT NULL;

    SELECT *
    FROM my_table
    WHERE regexp_like(col_2, '^[0-9]+$');


    Is there a more uniform way to do this such that it can work on multiple different versions of SQL?

    Continue reading...

Compartilhe esta Página