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!

Datediff in Days Hours Minutes from Same Field

Status
Not open for further replies.

elansienna

Technical User
Jun 18, 2004
44
US
Hello,

I need help creating a formula that will subtract two dates based on a status. However the dates resides in one database column. For example, when a status goes from "escalation level 1" to "escalation level 2" I need to subtract the time when the statuses change. I keep getting negative numbers. Any help will be appreciated
 
Here is my formula to caculate:

WhileprintingRecords;
datetimevar escdate ;
if {HDIncidentDetails.ActionId} = "ESCALATED LV2" then
escdate := {HDIncidentDetails.Date};

NumberVar TotalSec := datediff("s", escdate,{HDIncidentDetails.Date});
NumberVar lDays := Truncate (TotalSec / 86400);
NumberVar lHours := Truncate (Remainder ( TotalSec , 86400) / 3600) ;
NumberVar lMinutes := Truncate (Remainder ( TotalSec , 3600) / 60) ;
NumberVar lSeconds := Remainder (TotalSec , 60) ;




(if{HDIncidentDetails.ActionId} = "ESC TO 3RDPARTY" or
{HDIncidentDetails.ActionId} = "ESC TO SECURITY" or
{HDIncidentDetails.ActionId} ="ESC TO SYSTEMAD" or
{HDIncidentDetails.ActionId}="ESCL TO MESSA" or
{HDIncidentDetails.ActionId}= "ESCL TO NETWORK" or
{HDIncidentDetails.ActionId}= "ESCL TO POD" or
{HDIncidentDetails.ActionId} = "ESCL TO POSHW" or
{HDIncidentDetails.ActionId}="ESCL TO PRL/EVE" or
{HDIncidentDetails.ActionId} = "ESCL TO RADIANT" or
{HDIncidentDetails.ActionId} = "ESCL TO RIS/POS" or
{HDIncidentDetails.ActionId}= "ESCL TO SYSADMN"

then

"Level 2 to 3 " & Totext ( lDays , '##' ) + ':' +
Totext ( lHours , '00' ) + ':' +
Totext ( lMinutes , '00' ) + ':' +
Totext ( lSeconds , '00' )

else "Level 2 to 3 00:00:00:00");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top