Search code examples
sqlamazon-redshiftdatetime-conversion

Convert HH:MM:S to seconds int


I have two columns with the format YYYY-MM-DD HH:MM:SS When I do the difference between these two columns, my result has a format of the form HH:MM:SS

I would like to convert this result into seconds. How can I make it?

Example:

2019-06-15 19:27:33.045000 | 2019-06-15 19:27:22.298000 | 00:00:10.747

Solution

  • You can use DATEDIFF ( datepart, {date|timestamp}, {date|timestamp} ) function for more info check here

    for e.g

     select datediff(second, '0','05:15:40');