Subtract Days from the Current Date

Hi Everyone,

I’m trying to subtract 3 days from the current system date. I’m trying this syntax,
now.AddDays(-3).ToString(“ddMMyyyy”) and just return the value days minus 3.

My expectation is when the current date “06122021” and I want to substract 3 days before current date “03122021”, “04122021”, and “05122021”.

Thank you in advance.

Regards
Anggara

Hi @Anggara_Rahmadhani

Try the Below Expression
DateTime.ParseExact(DateTime.Now.ToString("ddMMyyyy"),("ddMMyyyy"),Globalization.CultureInfo.InvariantCulture).AddDays(-3).ToString(“ddMMyyyy”)

Regards
Gokul

Hi @Anggara_Rahmadhani

Is this your requirement?

Thank you.

Hi @Gokul001 @Jobin_Joy

Your syntax is just a return the value days minus 3 it means “03122021”.

My expectation is when the current date “06122021” and I want to substract 3 days before current date “03122021”, “04122021”, and “05122021”.

Hi @Anggara_Rahmadhani

You can Try with 3 different Assign and store the Value in the Variable

Sub1 = DateTime.ParseExact(DateTime.Now.ToString(“ddMMyyyy”),(“ddMMyyyy”),Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“ddMMyyyy”)
Sub2 = DateTime.ParseExact(DateTime.Now.ToString(“ddMMyyyy”),(“ddMMyyyy”),Globalization.CultureInfo.InvariantCulture).AddDays(-2).ToString(“ddMMyyyy”)
Sub3 = DateTime.ParseExact(DateTime.Now.ToString(“ddMMyyyy”),(“ddMMyyyy”),Globalization.CultureInfo.InvariantCulture).AddDays(-3).ToString(“ddMMyyyy”)

Regards
Gokul

Ya that is my solution before, but is it possible with 1 assign value to substract 3 days?

Hi @Anggara_Rahmadhani

You can Try with an Single Assign activity

DateTime.Now.AddDays(-1).ToString("ddMMyyyy")+" "+DateTime.Now.AddDays(-2).
ToString("ddMMyyyy")+" "+DateTime.Now.AddDays(-3).ToString("ddMMyyyy")

Regards
Gokul


2 Likes

Hi @Anggara_Rahmadhani,
Hope this workflow will help you :slight_smile:

arrDays.xaml (6.3 KB)

grafik

Enumerable.Range(1,3).Select(Function (x) now.Date.AddDays(-x)).Reverse().toArray
Enumerable.Range(1,3).Select(Function (x) now.Date.AddDays(-x).ToString("ddMMyyyy")).Reverse().toArray

3 Likes

Hi @ppr

Thanks a lot, by using function it is working as expected.

Best Regards.

Hi @tranthao240495

Thanks for your suggestion, really appreciate it!

Hi @Divyanshu_Divyanshu

Thanks for your suggestion, really appreciate it!

Hi @Gokul001

Thanks for your suggestion, really appreciate it!

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