Solved

Convert Systime to seconds

Posted on 2006-10-19
8
490 Views
Last Modified: 2010-04-05
Hi,

I need to do a calculation in my Select statement. The calculation is
((((1 + sysdate() - "job-dt-start") * 86400) +
         systime() - "job-tm-start" - 86400) / 86400)

in the above my job-tm-start is the time, its in  integer and stored as seconds.
but the systime is in HH:MM:SS format.  how to convert it to seconds.

Thanks
0
Comment
Question by:saroren
8 Comments
 
LVL 28

Expert Comment

by:TName
ID: 17767517
Do you mean something like this (get the system time and multiply it's hour and minute component corespondingly)?:

procedure TForm1.Button1Click(Sender: TObject);
var
SysTime:TSystemTime;
sec:Integer;
begin
   GetLocalTime(sysTime);
   sec:=sysTime.wHour*3600+sysTime.wMinute*60+sysTime.wSecond;
   ShowMessage(IntToStr(sec));
end;
0
 

Author Comment

by:saroren
ID: 17767572
No, I should be able to use it in the SQL statement.

select  "job-currop" ,"job-dt-start", "job-tm-start", systime,
((((1 + sysdate() - "job-dt-start") * 86400) +
     systime() - "job-tm-start" - 86400) / 86400)

from pub.job  where "act-ship" is null  

I am not able to do the above since the Systime is in the format  of "HH:MM:SS" and my job-tm-start has time stored in seconds (integer).


Thanks
0
 

Author Comment

by:saroren
ID: 17768245
Any help Please!!!!
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 28

Expert Comment

by:2266180
ID: 17768621
well that is not  adelphi quesiton but an sql question.
the following should help though I am not exactly sure if extract is supported in every DB server:

select  "job-currop" ,"job-dt-start", "job-tm-start", systime,
((((1 + sysdate() - "job-dt-start") * 86400) +
     extract (hour from systime())*3600+extract(minute from systime())*60+extract(second from systime()) - "job-tm-start" - 86400) / 86400)
0
 
LVL 5

Expert Comment

by:ewilde
ID: 17768805

which SQL server are  you  connect to?
what do you mean by stored as integer? do you mean that 1AM=3600?
in general, schematicly, maybe you should do:

cast(substring(systime,1,2) as integer)*3600
+ cast(substring(systime,4,2) as integer)*60
+ cast(substring(systime,7,2) as integer)


i'm not sure i anderstand your question...
regards,
ewilde.
0
 

Author Comment

by:saroren
ID: 17769289
I am using Progress Database

Hi Ciuly,

If i use the extract command it give me syntax error. So i guess its not supported.  is there any other way.
But thanks for your help

Hi Ewilde,

The current time is stored in a database field. the field is a integer format.
eg 12:45:13 is stored as 45913
 
you are right 01:00:00 AM is stored as 3600

I tried using your syntax it give an error "Inconsistent types"

so i just tried substring(systime,1,2)  still i have the same error.

Thanks
0
 
LVL 3

Accepted Solution

by:
cobi100 earned 500 total points
ID: 17769740
well I'm not sure what you're trying to accomplish, but to convert the systime into seconds, I think you can use second, minute and hour, so try this:


select  "job-currop" ,"job-dt-start", "job-tm-start", systime,
((((1 + sysdate() - "job-dt-start") * 86400) +
     (hour(systime())*3600+minute(systime())*60+second(systime())) - "job-tm-start" - 86400) / 86400)
0
 

Author Comment

by:saroren
ID: 17769862
Thanks cobi100,

Your solution worked.  
0

Featured Post

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.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

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

15 Experts available now in Live!

Get 1:1 Help Now