VB, the "seconds to" convert "minutes and seconds" format

Reference blog: http: //share.freesion.com/427239/

Database storage field worktime , (Type: varchar (6), Description: HHmmss), pages required to display HH: mm: ss

1.sql statement may be worktime data, converted into seconds

SELECT
    SUM(
        cast( substring( d13.`worktime`, 1, 2 ) AS DECIMAL ) * 3600 + cast( substring( d13.`worktime`, 3, 2 ) AS DECIMAL ) * 60+ cast( substring( d13.`worktime`, 5, 2 ) AS DECIMAL ) 
    ) AS 'totalTime'
FROM d13

2.vb background, when converted to minutes and seconds of the seconds format

label1.Text = Format(DateAdd("s", CDec(label1.Text), "00:00:00"), "HH:mm:ss")

The CDec (expression): is an expression parameter, converted to data type Decimal

https://docs.microsoft.com/zh-cn/office/vba/Language/Reference/User-Interface-Help/dateadd-function    About DateAdd method

DateAdd ( "s", the number of seconds, "00:00:00"), the second turn to the date contained in the minutes and seconds

Format (object, "Format"), where the format date data, return string

 

Guess you like

Origin www.cnblogs.com/xlaxx/p/11403676.html