Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Minus of time
Message
 
À
30/03/2004 06:23:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00890705
Message ID:
00890708
Vues:
18
You can convert the time to seconds & after substraction back again to time string:
m1  = TIME()
INKEY(5)
m2 = TIME()

? ConvertTime(ConvertTime(m2)-ConvertTime(m1), .t.)




FUNCTION ConvertTime(time_value, to_string)
LOCAL ret_val, c_hours, c_min, c_secs
IF to_string
    c_hours    = INT(time_value/3600)
    time_value = time_value - (c_hours*3600)
    c_hours    = IIF(c_hours<10,"0","")+ALLTRIM(STR(c_hours,15))
    c_min      = INT(time_value/60)
    time_value = time_value - (c_min*60)
    c_min      = IIF(c_min<10,"0","") + ALLTRIM(STR(c_min,15))
    time_value = IIF(time_value<10,"0","") + ALLTRIM(STR(time_value,10))
    ret_val    = c_hours+":"+c_min+":"+time_value
ELSE
   c_secs     = RIGHT(time_value,2)
   time_value = LEFT(time_value, LEN(time_value)-3)
   c_min      = RIGHT(time_value,2)
   time_value = LEFT(time_value, LEN(time_value)-3)
   ret_val    = VAL(time_value)*3600 + VAL(c_min)*60 + VAL(c_secs)
ENDIF
RETURN ret_val
That will work corectly if theese two time values are from ONE day, if the time 2 is from tomorow you can use a substraction of DATETIME values.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform