Find date and time values in text and then update another column

Tkachenko

In postgresql table, I have text column where dates are stored like this:

"Created at 2015-02-12 12:33:33"

or like this:

"Created at 2015-02-14 14:03:42 by Ivan" or "Start date: 2015-02-15 08:44:08"

There is just one date in text but for some row, there isn't date value at all.

example: "Created by Igor"

I need find these date and time values and update another timestamp column with these values.

Thank you!

Oto Shavadze

try this:

Note: this will work only in case, if date and time values are always in format, you posted in question.

UPDATE your_table SET
datetime_column = 
CASE 
WHEN text_column ~ '\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}' THEN regexp_replace(text_column, '.*(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}).*', '\1')::TIMESTAMP
END

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Find average values of a column in terms of date range of another column in R

From Dev

How we find Latest Date value and update in another column in Sql?

From Dev

Date & time text to column

From Dev

Find text from another column and replace them with adjacent values

From Dev

update time to date-time column in MySQL

From Dev

count unique text values based on condition in another column between date criteria

From Dev

count unique text values based on condition in another column between date criteria

From Dev

mysql update based on time stamp in another column

From Dev

the next closest date time from another column

From Dev

UPDATE sql column with value from another column based on a date column

From Dev

Access: UPDATE column with values from another table

From Dev

Reading a string column in xlsx with date and time values

From Dev

Reading a string column in xlsx with date and time values

From Dev

Sum of column values of dataframes with date time index

From Dev

Text format value for SharePoint Date and Time column

From Dev

Find values in one column that have association with certain values in another column

From Dev

Excel VBA find values in another column if it matches

From Dev

Find max values of a column in a time series dataset

From Dev

Update column value by querying concatenated column values with another table value

From Dev

Update table column with another column values of the same table using updateAll()

From Dev

Update same column with different values based another column

From Dev

How do I update column's values from another column?

From Dev

Update table's column with values from another table's column

From Dev

MYSQL update text in column with data from another column

From Dev

Adding the values of second column based on date and time of first column

From Dev

Adding the values of second column based on date and time of first column

From Dev

Multiple same values in Column A, need to find the greater date in column B

From Dev

How to find adjacent values in a column based on another column value in Sql

From Dev

Compare one column in excel to another column in excel and find duplicate values

Related Related

  1. 1

    Find average values of a column in terms of date range of another column in R

  2. 2

    How we find Latest Date value and update in another column in Sql?

  3. 3

    Date & time text to column

  4. 4

    Find text from another column and replace them with adjacent values

  5. 5

    update time to date-time column in MySQL

  6. 6

    count unique text values based on condition in another column between date criteria

  7. 7

    count unique text values based on condition in another column between date criteria

  8. 8

    mysql update based on time stamp in another column

  9. 9

    the next closest date time from another column

  10. 10

    UPDATE sql column with value from another column based on a date column

  11. 11

    Access: UPDATE column with values from another table

  12. 12

    Reading a string column in xlsx with date and time values

  13. 13

    Reading a string column in xlsx with date and time values

  14. 14

    Sum of column values of dataframes with date time index

  15. 15

    Text format value for SharePoint Date and Time column

  16. 16

    Find values in one column that have association with certain values in another column

  17. 17

    Excel VBA find values in another column if it matches

  18. 18

    Find max values of a column in a time series dataset

  19. 19

    Update column value by querying concatenated column values with another table value

  20. 20

    Update table column with another column values of the same table using updateAll()

  21. 21

    Update same column with different values based another column

  22. 22

    How do I update column's values from another column?

  23. 23

    Update table's column with values from another table's column

  24. 24

    MYSQL update text in column with data from another column

  25. 25

    Adding the values of second column based on date and time of first column

  26. 26

    Adding the values of second column based on date and time of first column

  27. 27

    Multiple same values in Column A, need to find the greater date in column B

  28. 28

    How to find adjacent values in a column based on another column value in Sql

  29. 29

    Compare one column in excel to another column in excel and find duplicate values

HotTag

Archive