Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Frank Cazabon
  Where is Frank Cazabon?
 
 Trinidad And Tobago
 Frank Cazabon
Subject: RE: Date And Time Function
Thread ID: 193317 Message ID: 193368 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Tuesday, September 9, 2008 10:13:31 PM         
   



> Hi Anders,
>
> that's some neat code, but I don't think it will handle time differences of more than a day.
>
> >
> >
lnSeconds= datetime2 - datetime1
> >  ltDiffTime = DTOT(DATE()) + lnSeconds 
> >  ?  TTOC(ltDifftime,2 ) 

> > You can put those three lines of code into a single line
> >
?  TTOC(DTOT(DATE())+(datetime2 - datetime1),2)

> > How the time is displayed depends on SET HOURS 24|12 and SET SECONDS ON|OFF.
> > If the difference is more than 24 hours, which is 24*60*60 seconds, you must calculate the differenc in days too:
> > The difference in days:
> >
 ? TTOD(datetime2)-TTOD(datetime1),'days'

> > If you need to separate out the hours, minutes and seconds, VFP is there for you:
> >
  ltTime = DTOT(DATE())+(datetime2 - datetime1)
> >  ? HOUR(ltTime),'hours',MINUTE(ltTime),'minutes',SEC(ltTime),'seconds'

> > -Anders
>
>
>
> Frank.
>
> Frank Cazabon
> Samaan Systems Ltd.
> www.SamaanSystems.com/

Hi Frank,

Well, that's noted in my post.
> If the difference is more than 24 hours, which is 24*60*60 seconds, you must calculate the differenc in days too:
> The difference in days:
>
 ? TTOD(datetime2)-TTOD(datetime1),'days'


This difference can also by multiplied by 24 and added to the hours. An exercise for the reader :-)

-Anders

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