Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subtract two times
Message
 
 
To
25/12/2004 08:27:19
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7
Miscellaneous
Thread ID:
00971289
Message ID:
00972219
Views:
17
Check Re: Calculate Time Message #866527
>
>i need help, to make add two times or more.
>
>how i can let mytextbox as hh:mm when i insert the time,
>i need to let hh not more 24 hours and not less than 0,and seconds not more 60,when i insert and when i make my adding operation.
>
>thanks very much.
>m.qasem
>>Did You copy & paste new code I posted, because I get the right results?
>>
>>
>>>hi,
>>>thank you, but still small problem
>>>
>>>if time2=13:38:37
>>>   time1=13:18:34  i get it as -00:00:0
>>>i think the result it must be as 00:20:03
>>>
>>>another ex..
>>>if time2=13:21:03
>>>   time1=13:19:21  i get it like -00:01:4
>>>i need it like 00:01:40
>>>
>>>thanks to much,
>>>m.qasem
>>>
>>>>Because I changed the function on ghe fly i missed something:
>>>>
>>>>USE newdnc
>>>>thisform.text9.value  = time()&& i a ctivate it at the begining run
>>>>thisform.text13.value = time() && after seconds i activate it via command bottom1.
>>>>thisform.text14.value = thisform.TIM(thisform.text13.value, thisform.text9.value)
>>>>replace time1 with thisform.text9.value,;
>>>>        time2 with thisform.text13.value,;
>>>>        time3 with thisform.text14.value
>>>>
>>>>
>>>>***** Method TIM of the form
>>>>   LPARAMETERS nSecs, nSec2
>>>>   LOCAL c_hours, c_min, c_znak, nLocSec
>>>>   IF .NOT. TYPE("nSecs") $"CT" .OR.;
>>>>      .NOT. TYPE("nSec2") $"CT" .OR.;
>>>>      TYPE("nSecs") # TYPE("nSec2")
>>>>      RETURN ""
>>>>   ENDIF
>>>>
>>>>   IF TYPE("nSecs") == "C" && Time string
>>>>      nLocSecs = VAL(LEFT(nSec2,2))*3600
>>>>      nLocSecs = nLocSecs + VAL(SUBSTR(nSec2,4,2))*60+ VAL(SUBSTR(nSec2,7,2))
>>>>      nLocSecs = nLocSecs - (VAL(LEFT(nSecs,2))*3600 ++ VAL(SUBSTR(nSecs,4,2))*60+ VAL(SUBSTR(nSecs,7,2)))
>>>>   ELSE
>>>>*** Suppose here You passed DateTime parameters
>>>>      nLocSecs = nSec2 - nSecs
>>>>   ENDIF
>>>>
>>>>   c_znak  = IIF(nLocSecs < 0, "-","")
>>>>   nSecs   = ABS(nLocSecs)
>>>>   c_hours = INT(nSecs/3600)
>>>>   nSecs   = nSecs - (c_hours*3600)
>>>>   c_hours = IIF(c_hours<10,"0","")+ALLTRIM(STR(c_hours,15))
>>>>   c_min   = INT(nSecs/60)
>>>>   nSecs   = nSecs - (c_min*60)
>>>>   c_min   = IIF(c_min<10,"0","") + ALLTRIM(STR(c_min,15))
>>>>   nSecs   = IIF(nSecs<10,"0","") + ALLTRIM(STR(nSecs,10))
>>>>
>>>>RETURN c_znak+c_hours+":"+c_min+":"+nSecs
>>>>
>>>>
>>>>Function TIME() returns string so if You have to save this TIME All fields must be Character type, this function also returns a string
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform