Skip to main content
Solved

Unable to Find DifferenceBetweenTwoDates


Forum|alt.badge.img

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/

 

Best answer by Syed Zaman Akhtar

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.

View original
Did this topic help answer your question?

2 replies

Abhay Naik
Forum|alt.badge.img+7
  • Navigator | Tier 3
  • 98 replies
  • December 20, 2023

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(dates[0], "%Y-%m-%d")
    date2 = datetime.strptime(dates[1], "%Y-%m-%d")

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

    return date_diff


Forum|alt.badge.img+3

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings