Articles in this section
Category / Section

How to Convert Hours, Minutes, and Seconds to Total Seconds

Published:

In data analysis, it is often necessary to convert time data into a different format to facilitate calculations or comparisons. One common conversion is from the time format (hh:mm:ss) to seconds. This conversion can be easily achieved in Bold BI using specific expressions.

Converting Minutes and Seconds to Total Seconds

To convert minutes and seconds to total seconds, you can use the following expression:

EXTRACT(MINUTES from [column_name])*60+ EXTRACT(SECONDS from [column_name])

This expression extracts the minutes and seconds from the specified column and converts them into seconds.

Converting Hours, Minutes, and Seconds to Total Seconds

If your time data includes hours, you can convert the entire time (hours, minutes, and seconds) to seconds using the following expression:

EXTRACT(HOUR from [column_name])*3600+EXTRACT(MINUTES from [column_name])*60+ EXTRACT(SECONDS from [column_name])

This expression extracts the hours, minutes, and seconds from the specified column and converts them into seconds.

image.png

image.png

By using these expressions, you can easily convert your time data into seconds, making it easier to perform calculations or comparisons in your data analysis.

Note: The above expression is supported by SQL-based data sources such as PostgreSQL, MySQL, Oracle, SQL Server, etc.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
RM
Written by Reethika Moovendhan
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied