Menghitung Selisih Jam

Ok saya agak lupa lupa ingat koding foxpro :v lama ga koding foxpro tp selalu punya backup jika ada kelupaan dan seterusnya jadi lancar deh, Ok biar enak ini saya berbagi cara itung selisis jam berikut sintaknya

</pre>
?timeDif(DATETIME(YEAR(DATE()),MONTH(DATE()),DAY(DATE()),16,30,00),DATETIME(YEAR(DATE()),MONTH(DATE()),DAY(DATE()),17,00,00))

** How to calculate the difference between two datetime variables in Hours, Minutes, Seconds ?
*********************************************************
** Author : Ramani (Subramanian.G)
** FoxAcc Software / Winners Software
** Type : Freeware with reservation to Copyrights
** Warranty : Nothing implied or explicit
*********************************************************
* How to run - Copy the following FUNCTION TimeDif
* and add in your project or at the end of Main.Prg
*
* Call this function as in here for example..
* WAIT WINDOW TimeDif(DateTime1,DateTime2)
* Or cDuration = TimeDif(frmDateTime,toDateTime)
*********************************************************
FUNCTION TimeDif
PARAMETERS tDateTime1, tDateTime2

LOCAL lReturn, myHours, myMinutes, mySeconds
lReturn = .t.

IF PARAMETERS() # 2
lReturn = .f.
ENDIF
IF ! VARTYPE(tDateTime1) = "T"
lReturn = .f.
ENDIF
IF ! VARTYPE(tDateTime2) = "T"
lReturn = .f.
ENDIF
IF lReturn
IF tDateTime2 > tDateTime1
mySeconds = tdateTime2 - tDateTime1
ELSE
mySeconds = tdateTime1 - tDateTime2
ENDIF
mySeconds=INT(mySeconds)
cTime = TRANSFORM(INT(mySeconds/3600),"9999")+":"+ ;
TRANSFORM(MOD(INT(mySeconds/60),60),"99")+":"+ ;
TRANSFORM(MOD(mySeconds,60),"99")
WAIT WINDOW "Time Difference = "+cTime
RETURN cTime
ELSE
=MESSAGEBOX("Pass to this function ;
From DateTime and To DateTime", ;
0+16,"Wrong Parameters")
RETURN lReturn
ENDIF
*********************************************************
** EOF
*********************************************************
<pre>

silahkan di copas dan dicoba hasilnya, hehe be

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: