First Date of a Month for multiple Dates

Hey,

need to convert each date in the two columns to the start date of the month.
Bildschirmfoto 2020-03-14 um 14.59.49
For every date in February I need 01.02.2020 and for every January 01.01.2020 and so on.
How exactly do I do that in Uipath?
A detailed description (preferably with screenshots) would be incredibly great, because I have only been dealing with Uipath for a short time and am not particularly good. :confused:

Help would be great.

Kind regards :slight_smile:

Use this
DateTimeVar = New DateTime(Year, Month, DateTime.DaysInMonth(Year,Month))

This gives you number of days in every month. You can take first or last date of a month as per your need

Example :strDay=DateTime.DaysInMonth(2020, 3).ToString()

2 Likes

But what do I have to do first?
Read Column and safe both in different variables ?
And where do I have to enter this code?

I’m sorry I’m really a total beginner :confused:

Can you please post your requirements ? .

I have an excel list that includes a posting date and goods issue date for each invoice. Now I would like to check whether the posting date is in the previous month of the goods issue date in order to reveal any fraud.
My idea was to determine the start of the month for each date and then to be able to check if posting date <goods issue date with an if formula.

Bildschirmfoto 2020-03-16 um 11.43.40

that’s the full list

Posting Date should not be older month than Goods Issue Date ?

Is that your requirement ?

We can directly compare both dates right?

It is important to check whether the posting date was in the previous month, as this would distort the month-end closing. so you can’t just check if it’s smaller

You can check the two date difference , if you want by

DateDiff(DateInterval.Day,DateTime.ParseExact(strDate, “dd-MMM-yyyy”, CultureInfo.InvariantCulture),strDate1)

Or

can compare month

Convert.ToDatetime(strdate).Month < Convert.ToDatetime(strdate1).Month

3 Likes

The second solution looks very nice

can you maybe show me every step in UiPath to implement the second solution ?

Create two variable as below and assign the value respectively
strDate = Goods Issue Date
strDate1 = Posting Date

In IF condition put this
Convert.ToDatetime(strdate1).Month < Convert.ToDatetime(strdate).Month

If it return true , Posting Date is previous Month else its good to proceed .

1 Like

Declaring the variables poses a challenge for me :confused:

  1. Excel Application Scope with workbook path of the Excel sheet
  2. Read Column with the Sheet and the Column where my Dates are. And Output in strDate (for Goods Issue Date Column) and strDate1(for the Posting Date column) ?

are these the right steps?

Why cant to use read range from Workbook

Use Read Range and get the data in DT
Loop and process it .

Please excuse the many questions, but as you can see I’m really very new to uipath.

So the steps are:

  1. Excel Application Scope with workbook path of the Excel Sheed.
  2. Read Range
    But how do I tell uipath that I want to get the column posting date and goods issue date from the excel sheet and how do I store them in a variable and what type of variable do I have to select?

inside Excel Application Scope
Read range would have given you Datatable .
You will use foreach to loop the datatable right?

Inside for each using assing activity , you can assign this value to variable

strpostdate = Row(“Posting Date”)

and so on

1 Like