# Final Builder - Read the build (run) time value in to a variable

**URL:** https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495
**Category:** Discussion
**Created:** [June 5, 2010, 7:59am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495 "2010-06-05T07:59:04Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 5, 2010, 7:59am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/1 "2010-06-05T07:59:04Z")

</div>

I am looking for a way to get the buid time ("Run Time" value,&nbsp;as shown in the Run dialog), in order to send this information on an email action, reporting how long the build took.&nbsp; I know that a variable like that is available in FinalBuilderServer, and I am looking for its equivalent in FinalBuilder.

Also, I am looking for a way to grab the BuildLog and add it into the email action's email body.

Any suggestions would be apriciated.

Thanks,

Hanoch

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [June 6, 2010, 10:33am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/2 "2010-06-06T10:33:41Z")

</div>

Hi Hanoch,   
  
 To get the elapsed time of the build you can either use the ‘Get DateTime’ action to get the current date & time at the start of the build and store it in a variable and then again at the end of the build, subtracting the starting the start time. Alternatively you can use the ‘Export Log’ action to export the log as XML and use the XML actions to extract the information, you can also use the ‘Export Log’ action to get the build log.   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [June 18, 2010, 11:42am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/3 "2010-06-18T11:42:27Z")

</div>

How do I subtruct the two start and end time values, and get back a duration (or a date-time) type?&nbsp; Is there a way to define a variable&nbsp;as a date or time type?&nbsp; I need to output the build time in a time&nbsp;format (e.g. - HH:mm:ss), and not as a number of seconds or number of minutes value.

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [June 20, 2010, 11:33am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/4 "2010-06-20T11:33:01Z")

</div>

Hi Hanoch,   
  
 The Get DateTime action allows you to subtract a date from the current date or you can use Javascript’s date object using the Run Script action to manipulate the dates.   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 5, 2010, 8:31am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/5 "2010-08-05T08:31:47Z")

</div>

It looks like the Get DateTime action only allows to add or subtract individual&nbsp;date/time components&nbsp;like seconds, minutes, hours, days, etc,&nbsp;but not a&nbsp;variable that holds the full date/time structure.

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [August 6, 2010, 1:30am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/6 "2010-08-06T01:30:17Z")

</div>

Hi Hanoch,   
  
 That’s correct, the action will only allow you to perform basic operations on the date. You’ll need to use script to add or subtract whole dates, here’s the reference I use when working with the Javascript date object:   
  
 URL: [http://www.w3schools.com/jsref/jsref\_obj\_date.asp](http://www.w3schools.com/jsref/jsref_obj_date.asp)   
  
 Let us know if you need help.   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 28, 2011, 5:09am UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/7 "2011-10-28T05:09:13Z")

</div>

This is not really simple to achieve in Final Builder.&nbsp; I found I had to use javascript as follows in the OnGetDate method of the Get Date (file) action:

// Note:&nbsp;Variable TimeTestsWereStarted is set by previous action:

// 'Put current date/time into variable' - using format 'ddd, dd, mmm yyyy hh:mm:ss' (this is important).

var finishTime = new Date(ModifiedDate);  
var startTime = new Date(TimeTestsWereStarted);  
var duration = new Date(finishTime - startTime);  
  
var hours = duration.getUTCHours() + "";  
if (hours.length == 1)  
{  
&nbsp;&nbsp; hours = "0" + hours;  
}  
  
var minutes = duration.getUTCMinutes() + "";  
if (minutes.length == 1)  
{  
&nbsp;&nbsp; minutes = "0" + minutes;  
}  
  
var seconds = duration.getUTCSeconds() + "";  
if (seconds.length == 1)  
{  
&nbsp;&nbsp; seconds = "0" + seconds;  
}  
  
TotalDuration = hours + ":" + minutes + ":" + seconds;

---

<div class="post-metadata">

### Author: ![rod\_prdsoftware](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/rod_prdsoftware/32/39_2.png) [@rod\_prdsoftware](https://www.finalbuilder.com/forums/u/rod_prdsoftware)
#### Post date: [June 27, 2015, 12:42pm UTC](https://www.finalbuilder.com/forums/t/final-builder-read-the-build-run-time-value-in-to-a-variable/1495/8 "2015-06-27T12:42:42Z")

</div>

Sorry for waking a zombie thread, but I found this today while searching the same thing. I just used the FinalBuilder “Get DateTime” action for both start and end times, then used the VB Script “Before Action” to calculate the minutes.   
  
 DATE\_MINUTES\_TO\_BUILD = DateDiff(“n”,DATE\_STARTTIME,DATE\_ENDTIME)
