Help needed with datetime manipulation

Hi, I have a process where I need to get data through http request. Every loop I have to add one day to date, but I don’t know how to do this. Please can someone help with this.
I have a variable “dateTo” with type of System.DateTime and the format needs to be yyyy-MM-dd

When I do a http request I’place this to the request(no problem for placing the value).

But the issues which I need help are:

  1. Add one day to dateTo variable in for each loop. for example the date is 1900-01-01 and in the next round it should be 1900-01-02. Also does the month change automatically if the date is 1900-01-31 and at the next round the month should be also changed?
  2. How to format the datetime format from 01/01/1900 to 1900-01-01?

Thank you very much allready in advance :slight_smile:

Next Day :

NewDate = YourDateVariable.AddDays(1)

New Date Format :

NewDateString = YourDateVariable.ToString(“yyyy-MM-dd”)

Cheers @hemuli

Hi @Ramprasad and thanks for yuor reply!

For some reason the year is lost with this:
I assign DateFrom = 1899-01-01
Log Message variable value = 01/01/1899 00:00:00
Then do
NewDateFrom = DateFrom.AddDays(1)
Log message variable value = 01/02/0001 00:00:00

newDateformat
newDateFrom = nextDateFrom.ToString(“yyyy-MM-dd”)
Log message newDateFrom variable value = 0001-01-02

Please help further with the year value. Should I assign DateFrom value somehow else?

you can try with this,

dateTo = dateTo.AddDays(1)

This should increment the day by 1

Please check below workflow.

image

DateFormat.xaml (5.3 KB)

Cheers @hemuli

1 Like

Fine let’s go one by one

For this

We can use this expression
Now.AddDays(-1).ToString(“yyyy-MM-dd”)
Before the for each row loop or for each loop use a

assign activity like this
Str_date = Now.AddDays(-1).ToString(“yyyy-MM-dd”)

Where Str_date is a string variable

Then inside the loop use a assign activity like this
Str_date = DateTime.ParseExact(Str_date,”yyyy-MM-dd”,System.Globalization.CultureInfo.InvariantCulture).AddDays(1).ToString(“yyyy-MM-dd”)

So for each iteration it will get added up

And the finally for this

Same
If the input is
str_input = “01/01/1900“

Then the output be like this
Str_output = DateTime.ParseExact(Str_date,”yyyy-MM-dd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

That’s all you are done
Kindly try this and let know for any queries or clarification
Cheers @hemuli

1 Like

@Ramprasad

Hi, And thanks! This is working like a charm, thank’s a lot!

1 Like

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