Cisco Support Community
Community Member

Count number of days between two dates

Hi Community,


I hope everyone is well.  I've been tasked to do something I haven't been able to do without a custom java class upload required. 


I need to read back the number of days left in a trial period for a product.  I can dip in the DB and get the date the trial started.  I need to count from that date to whatever date is now D[now] and see how many days they are into their trial period. For instance, if the customer started their trial on 10/20/2014 and today is 10/30/2014 they are 10 days into their trial period.   Anyone have a clever way to do this in the editor without a custom java class requirement?

Cisco Employee

Hi Matthew,Have you

Hi Matthew,

Have you considered database query and the SQL Server built-in DATEDIFF:



Community Member

Hi Matthew, As I understand,

Hi Matthew,


As I understand, you need find a differnce between two date.

So, you could try next:

define DateStart and DateFinish  (type Date) and variable diffInDays  (type int)

insert new "Do" step with next expression:

{  long diff = DateFinish.getTime() - DateStart.getTime();        

  long diffSeconds = diff / 1000 % 60;        

long diffMinutes = diff / (60 * 1000) % 60;        

long diffHours = diff / (60 * 60 * 1000);        

diffInDays = (int) ((DateFinish.getTime() - DateStart.getTime()) / (1000 * 60 * 60 * 24));





Hi,the easiest approach would


the easiest approach would be to have the database query return this information for you. What is the type and version of your database server? Most SQL dialects have a helper function to return the difference between two date objects.

Also, when you do that database dip, what is the type of the column? String? Date? Datetime?



Hi Matthew,You can try this.

Hi Matthew,

You can try this. Hope this will help you.

Today date is = 11/2/2014

The trial Start Date =10/20/2014


And I set the variable as below;


And in the "diff_Between_Days" store the value of difference between two days.



CreatePlease to create content