Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help calculating date difference

Status
Not open for further replies.

ro1016

Programmer
Mar 30, 2006
13
US
Hi every body,

I'm writing a stored procedure.
I have a few dates in a table,1.Request_date 2.assigned_date,3.start_date,4.end_date
I need to perform some calculation to figure out the difference between dates, and see how many hours or minute or seconds where spent working on a project and display the result in a report. Is there a function like date between in oracle that would do that for me? If not, how can I do this?
Any input would be appreciated.

Thank you
 
Thank you jshurst,

but I think I need to be more clear about this, I need to
show the result in terms of hours,minutes and seconds,so at the recordset level when I'm doing the select statement and doing the datediff, how do I read the hours and minutes
into variables? I don't know if I'm making sense but here is my stored procedure:

alter procedure CalculateDuration

As

SELECT TOP 100 PERCENT lp.LastName AS ResolverLastName,
ti.[tiIdNumber] AS tiIDNum,
ti.[tiStatus] AS TicketStatus,
ti.[tiAssignDate] AS AssignDate,
ti.[tiStartDate] AS cketStartDate,
ti.[EndDate] AS TicketEndDate, ti.[20tiResolver] AS Resolver,
re.[reStartDate] AS StartDate,
re.[reAssignDate] AS AssignDate,
re.[reEndDate] AS EndDate,
lp2.FirstName + ' ' +lp2.LastName As Requestor,
substring(bu.BusinessUnitDesc,1,50) as Org,
(case ti.[tiAssignDate]
when ''
then DateDiff(s,re.[reStartDate],getdate())
else
DateDiff(s,re.[reStartDate],ti.[tiAssignDate])
end ) as sAssignmentTime,

(case ti.[tiAssignDate]
when ''
then DateDiff(hh,re.[20reStartDate],getdate())
else
DateDiff(mm,re.[20reStartDate],ti.[20tiAssignDate])
end ) as mAssignmentTime


FROM tables
 
sorry, there were some mistakes in that. Here is the sp

alter procedure CalculateDuration

As

SELECT TOP 100 PERCENT lp.LastName AS ResolverLastName,
ti.[tiIdNumber] AS tiIDNum,
ti.[tiStatus] AS TicketStatus,
ti.[tiAssignDate] AS AssignDate,
ti.[tiStartDate] AS cketStartDate,
ti.[EndDate] AS TicketEndDate, ti.[20tiResolver] AS Resolver,
re.[reStartDate] AS StartDate,
re.[reAssignDate] AS AssignDate,
re.[reEndDate] AS EndDate,
lp2.FirstName + ' ' +lp2.LastName As Requestor,
substring(bu.BusinessUnitDesc,1,50) as Org,
(case ti.[tiAssignDate]
when ''
then DateDiff(s,re.[reStartDate],getdate())
else
DateDiff(s,re.[reStartDate],ti.[tiAssignDate])
end ) as sAssignmentTime,

(case ti.[tiAssignDate]
when ''
then DateDiff(mm,re.[reStartDate],getdate())
else
DateDiff(mm,re.[reStartDate],ti.[tiAssignDate])
end ) as mAssignmentTime


FROM tables
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top