{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1125,"path":"api-reference/server-api-reference/c_WorkflowDurationAPI.md","title":"WorkflowDuration - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# WorkflowDuration- Global\n\nThe WorkflowDuration script include provides methods to calculates the duration \\(in seconds\\) based on the variables of a workflow activity. It is an interface between Workflow Timer\\(\\) and DurationCalculator\\(\\).\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## WorkflowDuration - addSeconds\\(GlideRecord record, Number amount\\)\n\nAdds the number of seconds to the specified start date/time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|record|GlideRecord|description|\n|amount|Number|amount|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True, if object was successfully created.|\n\n## WorkflowDuration - calculate\\(GlideRecord record\\)\n\nCalculates the number of seconds and the due date.\n\n|Name|Type|Description|\n|----|----|-----------|\n|record|GlideRecord|The record that contains the fields with the schedule, timezone, and date/time information. This is almost always **activity.vars.\\_\\_var\\_record\\_\\_**.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - calculateTimeLeft\\(GlideRecord record\\)\n\nCalculates the number of seconds remaining to the specified end date/time.\n\n|Name|Type|Description|\n|----|----|-----------|\n|record|GlideRecord|The record that contains the fields with the schedule, timezone, and date/time information. This is almost always **activity.vars.\\_\\_var\\_record\\_\\_**.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - getEndDateTime\\( \\)\n\nReturns the end date/time set by a call to calculate\\(record\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|GlideDateTime|The end date/time.|\n\n## WorkflowDuration - getSeconds\\( \\)\n\nReturns the seconds value that was set by a call to calculate\\(record\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|The number of seconds set by a call to calculate\\(record\\).|\n\n## WorkflowDuration - getTotalSeconds\\( \\)\n\nReturns the totalSeconds value that was set by a call to calculate\\(record\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|The total number of seconds set by a call to calculate\\(record\\).|\n\n## WorkflowDuration - setEndDateTime\\(String dt\\)\n\nSets the end date/time to use when calculating the remaining time.\n\nTo convert the value into the GlideDateTime internal format, use GlideDateTime.getValue\\(\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|dt|String|The end date/time to use.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - setEndDateTime\\(GlideDateTime dt\\)\n\nSets the end date/time to use when calculating the remaining time.\n\nTo convert the value into the GlideDateTime internal format, use **GlideDateTime.getValue\\(\\)**.\n\n|Name|Type|Description|\n|----|----|-----------|\n|dt|GlideDateTime|The end date/time to use.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - setStartDateTime\\(String dt\\)\n\nSets the start date/time to use in the calculations.\n\n|Name|Type|Description|\n|----|----|-----------|\n|dt|String|The start date/time to use, in GMT.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - setStartDateTime\\(GlideDateTime dt\\)\n\nSets the start date/time to use in the calculations.\n\nTo convert the value into the GlideDateTime internal format, use GlideDateTime.getValue\\(\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|dt|GlideDateTime|The start date/time to use.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - setUsedSecs\\(Number secs\\)\n\nSets the **used seconds** compensation, where the number of seconds is the number of seconds inside of any schedule.\n\nCan be a -ve number, which extends the duration.\n\n|Name|Type|Description|\n|----|----|-----------|\n|secs|Number|The number of used seconds to set.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## WorkflowDuration - setWorkflow\\(Object schedule, Object timezone\\)\n\nSets the workflow schedule/timezone. Used for **schedule\\_type** **workflow\\_schedule** and **timezone\\_type** **workflow\\_timezone**\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|schedule|Object|The schedule to use. Usually from the workflow **context.schedule**.|\n|timezone|Object|The timezone to use. Usually from the workflow **context.timezone**.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n"}}