Workflow Soluiton

 View Only

Comparing Date/Time Values by Timespan 

Nov 04, 2008 01:53 PM

On occasion, you may need to compare or evaluate two values based on time as well as a calendar date, specifically any time under a 24-hour period (and therefore not equal to a full day). The process detailed below is an example of a timespan comparison that I created.

In this scenario, we will compare two dates that contain a time value - one representing the log in time of the user, and the other representing a due date/time. This can be utilized for various tasks or response actions.

For instance, you may need to respond to a particular request within 2 hours of the due date/time. The logic in this workflow can be applied in an auto start process that will send you a notification email warning you of the approaching deadline.

For this example, we will create a simple web form project that will provide a true/false value based on whether or not the current time is within 2 hours of the deadline/due date.

  1. Open a new Web Forms project.
  2. Add and connect a Get Current Date component after the Start component. Double-click the Get Current Date component and for the Output Variable Name, use "Today". Click OK to exit the editor window.
  3. Add a Date Greater Than component after the Get Current Date component and connect the two. Double-click the Date Greater Than component to edit it.
  4. For First Date Variable Name, select Today. For Second Date, click the ellipse and select Dynamic Model.
  5. In the Edit Embedded Decision Model window for your Dynamic Model, add an Add New Data Element component after the Start component. Double-click the Add New Data Element component to edit it.
  6. For Data Type, select Date (Date Time) . For Value, provide your due date. In this example, we are using 10/30/08 10:00AM (this document is being written at 7:00AM of the same day). For Variable Name, type FauxDueDateAndTime. Click OK to exit the editor window.
    Note: The Add New Data Element component could be swapped out for any data that may be passed into your process, such as a task due date.
  7. Add a Subtract Timespan from Date component after your Add New Data Element. Double-click the component to edit it.
  8. For Input Date, select the Process Variable of FauxDueDateAndTime. For Output Variable Name, type FauxDueDateMinus2Hours. For Time Span to Subtract, use the Constant Value of 02:00:00, representing 2 hours. Click OK to exit the editor window.
  9. Double-click the End component and click the ellipse next to Result. Select the Value From Data of FauxDueDateMinus2Hours.
  10. Click OK. With this Dynamic Model, you will now be comparing the current date/time against your due date, minus 2 hours.
  11. Click OK three times to return to your primary model.
  12. Add two Form Builder components to the primary model. Connect the true path of your Date Greater Than component to one form, and the false path to the other. Name each component appropriately so as not to confuse them.
  13. Double-click the true path form to edit it. Add a button labeled End as your output. On the form, add a label with the text "TRUE: The Date and Time of Now is greater than the Due Date minus 2 hours". Click OK to exit the editor window.
  14. Double-click the false path form to edit it. Add a button labeled End as your output. On the form, add a label with the text "FALSE: The Date and Time of Now is NOT greater than the Due Date minus 2 hours". Click OK to exit the editor window.
  15. Connect the true path form and false path form to the model's End component.

Your primary model should now look something like this:

When this project is run, you will see the form that corresponds to whether or not the current time is greater than your designated due date, minus two hours.

Statistics
0 Favorited
4 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
jpg file
6111.jpg   2 KB   1 version
Uploaded - Apr 10, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.