Skip to main content
Ground Control | Tier 1
December 20, 2023
Solved

Unable to Find DifferenceBetweenTwoDates

  • December 20, 2023
  • 2 replies
  • 156 views

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.

    2 replies

    Abhay Naik
    Navigator | Tier 3
    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

    Abhay Naik
    Navigator | Tier 3
    December 28, 2023

    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.

    Syed Zaman Akhtar