Subtract Days from the Current System Date

Hi Everyone,

I am trying to subtract 3 days from the current system date. from the below syntax,
datetime.Now.ToString(“dd-MM-yy”)

Can anyone advice how to solve this and may I know can I use that syntax in the
“=IF(ISNA(VLOOKUP(A2,‘18-01-19’!A:D,1,FALSE)),”“New Deal”“,”“Old Deal”“)”
Instead of hardcoding date in the vlookup formula can I use dynamic value ?

Thank you very much in advance

Regards
Vishnu

You can use DateTime.Now.Add(-3).ToString("dd-MM-yy")

1 Like

and to ad dynamic values here use a variable.
like 1st use a assign activity:
date_var = DateTime.Now.Add(-3).ToString("dd-MM-yy")

then in your expression:
“=IF(ISNA(VLOOKUP(A2,‘"+date_var+"’!A:D,1,FALSE)),”“New Deal”","“Old Deal”")"

this should do the job

1 Like

Hi Nadim,

Much appreciated for your quick reply. while using the Add is giving the result in the Integer type. Would you please suggest what type of variable I can use for this?

Thank you

Regards
Vishnu

1 Like

Thanks A lot Karthik, But I am still facing the problem with the Type of variable that I can use.

Regards
Vishnu

it will be a string as you are doing a toString() in the expression :slight_smile:

3 Likes

You variable should be String data type.

2 Likes

@nadim.warsi
I guess its DateTime.now.AddDays(-3).ToString(“dd-MM-yy”)

@winningvish
This happens if you use (Add) so replace it with AddDays.

Regards,
Pathrudu

4 Likes

yes,DateTime.now.AddDays(-3).ToString(“dd-MM-yy”) is correct. if you use Add(-3) then you will get a error like integer cannot be converted to system.timespan.

2 Likes

Correct pathrudu, by using Adddays it is working as expected.

Thank you

2 Likes

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