Skip to main content

I am unable to find “DifferenceBetweenTwoDates” under actions.

Please advise how to get that.

This is my control room url.

https://community.cloud.automationanywhere.digital/

 

Hi @MadhuDampuri ,

 

You can use below python script in python commands to find the difference between 2 dates. The input date format should be in YYY-mm-DD (ex: 2023-12-31). The output will be in days.

 

from datetime import datetime

def date_diff_in_days(date_range):
    # Split the input string into two dates
    dates = date_range.split('//')

    # Convert the dates to datetime objects
    date1 = datetime.strptime(datesr0], "%Y-%m-%d")
    date2 = datetime.strptime(datess1], "%Y-%m-%d")

    # Calculate the difference in days
    date_diff = abs((date2 - date1).days)

    return date_diff


Use the VB script for calculating the difference:

 

I have converted the format as well coz of the way VBScript handles and interprets date values. In VBScript, the default date format is typically mm/dd/yyyy, which is in line with the date format commonly usd in the US.

When you provide a date string to VBScript for date-related operations, like calculating the difference between two dates, VBScript attempts to parse this string according to its default date format.


Reply