How to find the days from dates

Hi All,

i have excel which consists of date column and i want to find out the extact days of that date from today’s date and write to the another column like Ageing.
e.g
today’s date - excel date = actual days
20-Mar-2023(want to use system date not hardcode date) - 02-Mar-2023 = 18 days and write in adjacent column. excel data for reference

image

Thanks in advance

Hi @RAKESH_KUMAR_Tiwari ,

Could you try the below :

DateDiff(DateInterval.Day,CDate(row("Invoice Date").ToString),Now)

The above expression is in considering that you are already looping through the data in the Excel using a For Each Row Activity.
image

1 Like

Hi,

@RAKESH_KUMAR_Tiwari ,

Is there a need to create NoOfDays variable ? You could directly assign it to the datatable row

CurrentRow("Ageing") = DateDiff(DateInterval.Day,CDate(CurrentRow("Invoice Date").ToString),Now)

The error is because, the NoOfDays is a String variable, where as the Output from DateDiff is an Long type variable. You can easily convert it to String using .ToString at the end.

1 Like

ok, thanks for explanation,

one more thing i want to write in in Ageing column for each row of invoice date after calculation, how to amke that expression so that it will write one after the other.

image

@RAKESH_KUMAR_Tiwari ,

If you’re using the Write Range Activity inside the For Each Row Activity, just keep it outside after the For Each Row activity and check the execution.

yes, it’s working fine, pls explain the expression what it is doing.

CurrentRow(“Ageing”) = DateDiff(DateInterval.Day,CDate(CurrentRow(“Invoice Date”).ToString),Now)

@RAKESH_KUMAR_Tiwari ,
DateDiff is an inbuilt method of DateTime class, that lets us calculate the difference between two DateTime type values.

We can also access the syntax of the DateDiff method from the intellisense of the Studio.

The Syntax states that :

  1. First parameter to be passed is the DateInterval type, which specifies if we need the difference in days or Months or Years.
  2. Second parameter is first Date value which should be of type Date
  3. Third parameter is the Second date value.

The other parameters are optional.

Additionally, since the data in your case is present in Excel/Datatable, we would need to convert it to DateTime type which is done using CDate() method.
Now - Represents the current Date and Time.

1 Like

Hi @supermanPunch ,

i have one use case where there is data in excel as a table, consider below img

image

now , i want to send email with this details to user as HTML format, how to achieve it?

Thanks in Advance

@RAKESH_KUMAR_Tiwari ,

I believe the Initial Requirement of this Topic is satisfied/solved. You could create another Topic on this requirement, so that we can provide the help on it separately.

Although for the mentioned, there are many posts already on “How to send Table/Datatable in Email”, Search for the topics in Here and you would find many results. You could adopt one of them.

One such post is provided below :

If you have further questions on this requirement, feel free to create a Separate Topic.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.