Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Anil Sharma
  Where is Anil Sharma?
 ludhiana
 India
 Anil Sharma
 To: waseem waheeb
  Where is waseem waheeb?
 cairo
 Egypt
 waseem waheeb
Subject: RE: Date And Time Function
Thread ID: 193317 Message ID: 193329 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Tuesday, September 9, 2008 2:20:35 PM         
   



> Dear
> Can help me it so important
> I want found the deferent between 2 date
> Example
> Date1 - Date2 = day-hour-minute-second
> 2008-09-09 11:55:12 - 2008-09-09 11:51:32= 04:02
>
> Waseem Waheeb


****Edited Post... After checkin the Anders Code i come to know that my code is wrong so just edited with write one!
hi Waseem
First your result should be 03:40 :)


  
LOCAL lDate1, lDate2,lDays,lH1,lH2,lm1,lm2,ls1,ls2,lHrs,lMinute,lSeconds,lText2Display
SET SECONDS ON
SET HOURS TO 24
ldate1 =CTOT([09.09.2008 11:51:32])
ldate2 =CTOT([09.09.2008 11:55:12])
  
LDAYS = TTOD(lDate2) - TTOD(lDate1)
 
lh1 =SUBSTR(TTOC(lDate1),12,2)
lh2 =SUBSTR(TTOC(lDate2),12,2)

lm1 =SUBSTR(TTOC(lDate1),15,2)
lm2 =SUBSTR(TTOC(lDate2),15,2)

ls1 =SUBSTR(TTOC(lDate1),18,2)
ls2 =SUBSTR(TTOC(lDate2),18,2)

 
lHrs=  VAL(lh2) - VAL(lh1)

lMinute=  VAL(lm2) - VAL(lm1)
lSeconds=  VAL(ls2) - VAL(ls1)

IF lSeconds   < 0
lMinute = lMinute -1
lSeconds  = 60 +(lSeconds)
ENDIF

IF lMinute  < 0
LHrs = lHrs -1
lMinute  = 60+(lMinute)
ENDIF
 
IF lHrs   < 0
LDAYS = lDays -1
lHrs  = 24+(lHrs)
ENDIF
 
lText2Display = " Days = "+ALLTRIM(STR(lDays)) + " Hours "+ALLTRIM(STR(lHrs))+ " Minutes : "+ALLTRIM(STR(lMinute)) + " Seconds : "+ALLTRIM(STR(lSeconds))
MESSAGEBOX(lText2Display)



Anil
(Fox is the solution for almost everything!!)

ENTIRE THREAD

Date And Time Function Posted by waseem waheeb @ 9/9/2008 1:34:31 PM
RE: Date And Time Function Posted by Frank Cazabon @ 9/9/2008 1:58:28 PM
RE: Date And Time Function Posted by waseem waheeb @ 9/9/2008 2:02:44 PM
RE: Date And Time Function Posted by Frank Cazabon @ 9/9/2008 2:19:43 PM
RE: Date And Time Function Posted by Anil Sharma @ 9/9/2008 2:20:35 PM
RE: Date And Time Function Posted by waseem waheeb @ 9/9/2008 2:36:26 PM
RE: Date And Time Function Posted by Anil Sharma @ 9/9/2008 7:20:24 PM
RE: Date And Time Function Posted by Anders Altberg @ 9/9/2008 2:52:04 PM
RE: Date And Time Function Posted by Anil Sharma @ 9/9/2008 3:26:17 PM
RE: Date And Time Function Posted by Anders Altberg @ 9/9/2008 3:50:29 PM
RE: Date And Time Function Posted by Frank Cazabon @ 9/9/2008 9:48:32 PM
RE: Date And Time Function Posted by Anders Altberg @ 9/9/2008 10:13:31 PM
RE: Date And Time Function Posted by Frank Cazabon @ 9/9/2008 10:35:41 PM