Nintex Connect

The Official Community Site for Nintex Software Products, including Nintex Workflow 2007, 2010 and 2013; Nintex Workflow for Project Server 2010; Nintex Reporting 2008 and Nintex Analytics 2010; Nintex Forms 2010; Nintex Live and Nintex SmartLibrary.
Welcome to Nintex Connect Sign in | Join | Help
in Search

Converting time to decimal value

Last post 10-23-2011, 8:27 PM by Peter D. 1 replies.
Sort Posts: Previous Next
  •  10-21-2011, 6:28 AM 19970

    Converting time to decimal value

    I’ve got a bit of a challenge with this one. I’m extracting a number of different values from a non-SharePoint MS SQL database and one of these values is a time that is retrieved as a string in the following format “hhmmss” (e.g. “093000”). What I am trying to do within my workflow is convert this value into a decimal representation of the hours and minutes (e.g. 093000 becomes 9.5).

     I’m not sure of the best approach to doing to this so I would be interested to know if anyone has any suggestions. One approach I have been trying to get to work is first converting the extracted string to a date/time value using the Convert action (which is successful) and then using the fn-DateDiffHours inline function to use this date/time and today’s date at 12:00am to give me the difference in hours. However, I can’t get this inline function to successfully perform this calculation and instead it causes my workflow to error with the following message: Error parsing value. Value 'fn-DateDiffHours({8/31/2011 9:59 AM},{8/31/2011 12:00 AM})' is not compatible with the selected output variable type Number (double).

    Should I be trying something else?

  •  10-23-2011, 8:27 PM 20000 in reply to 19970

    Re: Converting time to decimal value

    Hi,

    What I would do in this case is split the initial value into 3 sections using a fn-subString() inline function. You can then have 3 text variables the first containing the hours, the 2nd the minutes and the third the seconds.

    What I would then do is convert each of these to number variables using the convert value action.

    You can then convert each value to seconds. for example 1 hour has 60*60 seconds then convert he minutes and add all the values together. You then have the total in seconds. Once you have this you can divide by 60 for minutes and divide by 60 again for hours.

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems