Subject Re: [firebird-support] How to do Time calculation
Author Martijn Tonies
Hi,

>I have one small question(doubt) that how to subtract time.
>
>Let me explain in detail:
>
>I have one table, say "Test_Data" and I have three fields as follows:
>
>1) EmpNo Varchar(15)
>2) dtDate Date
>3) tmTime Time
>
>This table will contain entry time as well as exit time for a perticual day
>for a perticular employee. Now here i >want to calculate the total time
>employees worked for given two different dates or two same dates, how do i
> >achieve this.

For starters, it would be easier if you store "date and time" in the
same column:

1) empno
2) clockdatetime

Next, the result of one particular date/time minus another does not
result in a date or time, you should know that. It results in a "duration",
which is stored in a format you would like, eg "integer" (depending on
how precise you want it).

Subtracting one "clockdatetime" from another (end-start) gives you the
duration.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com