Solved

Comparing my Table Date, Time fields with System Date&Time.

Posted on 2002-07-25
11
180 Views
Last Modified: 2010-04-04
My Dbase Table have fields 'ST_TIME' Character (10) for Time and 'ST_DATE' Date(8) field for Date. I am using these field to save System Input Time and Date from my application.
I have a calculation in my logic to compare this table 'ST_DATE, 'ST_TIME' with the system present Date&Time. If the difference is more than 48 hours I have some logic to do(like closing the record).
 So how can I compare that table 'ST_DATE', 'ST_TIME' with system present Date&Time to find 48 hours difference.
My Table is saving time like :- 11:56:32PM
                   date like :- 25/07/2002

 Please help me to calculate/compare 48 hours time difference. For ex.if do
(Table.FieldByName('ST_TIME').AsSting - TimetoStr(Time)).

 I am getting errors. Please tell me the way to do this.
0
Comment
Question by:VENKAT
  • 6
  • 5
11 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7176635
try

if time-strtotime(Table.FieldByName('ST_TIME').AsSting) > 2 then ...

but attention
your apptimeformat or systemtimeformat must
be set to this format

11:56:32PM

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 20 total points
ID: 7176642
oops something missed->ST_Date

replace this

if time-strtotime(Table.FieldByName('ST_TIME').AsSting) > 2 then ...

with

if now-(
   Trunc(strtodate(Table.FieldByName('ST_DATE').AsSting))+  
   Frac(strtotime(Table.FieldByName('ST_TIME').AsSting))
   ) > 2 then ...

just from head, not tested

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7176645
but attention
your apptimeformat or systemtimeformat and
your appdateformat or systemdateformat
must be set to your format

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 1

Author Comment

by:VENKAT
ID: 7176690
hi kretzschmar
       thank u. But How can I check with my Date and Time both with present Date and Time to get 48 hours difference.
0
 
LVL 1

Author Comment

by:VENKAT
ID: 7176694
hi kretzschmar
       thank u. But How can I check with my Date and Time both with present Date and Time to get 48 hours difference.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7176699
now() gives you the current-datetime,
see above, the if statement does all for you

one day is represented by 1

meikl ;-)
0
 
LVL 1

Author Comment

by:VENKAT
ID: 7176701
hi kretzschmar
       thank u. But How can I check with my Date and Time both with present Date and Time to get 48 hours difference.
0
 
LVL 1

Author Comment

by:VENKAT
ID: 7176705
sorry I think my page was refresh..i will check first.
0
 
LVL 1

Author Comment

by:VENKAT
ID: 7176711
I used like this...my ST_DATE is date field which have date like 25/07/2002.
        if now - (
          Trunc(TimeTable.FieldByName('ST_DATE').AsDateTime)+
          Frac(strtotime(TimeTable.FieldByName('ST_TIME').AsString))
          ) > 2 then
...Now I am getting error like 25/07/2002 is not valid DateTime.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7176718
well,
your system-shortdateformat seems
to be other than dd/mm/yyyy

at appstart (for ex. in the create-event of your mainform)
set the dateformat appwide with

shortdateformat := 'dd/mm/yyyy';
dateseparator := '/';

meikl ;-)
0
 
LVL 1

Author Comment

by:VENKAT
ID: 7176782
thank u..success.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now