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!

How to add DateTime field and number field 1

Status
Not open for further replies.

mouser4069

Technical User
Feb 28, 2007
11
US
I am using CR9 against a database on a SQL server.

I have a report where I list a starting time (a DateTime field). I need to add the duration to that DateTime field to create an ending time. The problem I am encountering is that the duration is two separate number fields (created with separate entries for hours and minutes).

Can someone help with how I go about doing this?
 
Code:
local datetimevar endingtime;
endingtime := dateadd('n', minutesfield, startingtime);
endingtime := dateadd('s', secondsfield, endingtime);
 
startingtime is your database field for startingtime
minutesfield is your database field for minutesfield
secondsfield is your database field for secondsfield
endingtime is the output of the formula
 
crap. I need to start reading. We were talking about hours and minutes. So the correct formula is
Code:
local datetimevar endingtime;
endingtime := dateadd('h', hoursfield, startingtime);
endingtime := dateadd('n', minutesfield, endingtime);

startingtime is your database field for startingtime
hoursfield is your database field for hoursfield
minutesfield is your database field for minutesfield
endingtime is the output of the formula
 
Thank you - it took me a while to get back to this, but it worked perfectly!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top