Converting duration in seconds to time format

topic: 

$SAMPLECODE$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19

lnSeconds = 5678
* The year and month are irrelevant here. The day should end on '0' if duration >= 24 hours
ltDt = {^2000/01/10 00:00:00} + lnSeconds

* VFP 9.0 only
* Time part only
? SUBSTR(TTOC(ltDt,3),12)
* Days(0-9) + Time part 
? STRTRAN(SUBSTR(TTOC(ltDt,3),10), "T", " ")

* Previous VFP versions
* Time part only
? TRANSFORM( SUBSTR(TTOC(ltDt,1), 9), "@R 99:99:99")
* Days(0-9) + Time part 
? TRANSFORM( SUBSTR(TTOC(ltDt,1), 8), "@R 9 99:99:99")


Comments