Calculate no of days between two dates in Textbox

Dear all
I have two dates in textboxes in the format of dd-MM-YYYY
1 button (calc overall Tx time)

When the button is clicked i wanted to calculate the difference (in days) between the two dates in textboxes and display it. I have tried hard but ended in vain. Your help is highly appreciated. Thanks in advance.

Try

Thanks for the reply. I am a novice programmer. I have tried something on your suggestion but i dont know where i am going wrong. Please help me in this regard

for community2

You have a date formatting issue.

MakeInstant( from ) Returns an instant in time specified by MM/dd/YYYY hh:mm:ss or MM/dd/YYYY or hh:mm.

The example uses MM/dd/YYYY. You are providing the date as MM-dd-yyyy . Unfortunately that format will not work with the MakeInstant Block.

You enter the date as 05-22-2020 . In your TextBox, either enter the date as 05/22/2020 or write a procedure to replace the ’ - ’ in the dates you enter with a slash " / " when you format the date.

Try entering the date using a / instead of a - .

I have changed the format, still the coudlnt figure out.

Basic requirement for my calculation. Is there any way around to do it. Thanks in advance.

Here is another (slightly more long winded way) which you might find easier ?

This is the root of all your problems.

That’s why the Date Picker was invented, to not allow anything but a date.

Here is how to do this with DatePickers

It appears you cannot take a typed date from textboxes in the algorithm. I made an assumption they would work (an adapted code I already had using DatePickers).

DaysBetweenDates.aia (4.2 KB)

Regards,
Steve

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