UI Path Date logic

Hi - does UI Path always think in US date format. Had an issue that if my computer is not set to US format then UI Path will not always accurately determine if an email is older than today.

Hi @harri.w.morgan,

Can you explain your query a bit in detail?

Regards,
@90s_Developer

I want to move all emails in Folder A that are older than today into Folder B

My computer and therefore outlook are set to UK/European date format DD/MM/YY.

Between day 1 and day 12 of the month UI Path makes incorrect decisions on what is older than today. I worked out if I switch my computer to US format then it will no longer make these errors. Assumption being UI Path ‘thinks’ in US format and gets confused when faced with European format.

I want to remove the dependency of having to switch my computer to US formatting to run my automation.

Hope this helps and thanks for looking at it.

@harri.w.morgan,

In the end, in which date format do you need to process UK or US?

Regards,
@90s_Developer

UK Format

@harri.w.morgan,

First, retrieve the mail received date&time into a string variable [varMailDateTime]
Then, create another variable called [varConvertDateTime] which holds the converted format date-time from US format to UK format.

Use the below syntax to convert the format from US to UK

varConvertDateTime = DateTime.ParseExact(varMailDateTime, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

To retrieve, mail’s date & time: item.Headers(“Date”)

Hope this solves your issue

Regards,
@90s_Developer

Thanks @90s_Developer - sorry i’m very much beginner level. What activity do I utilise to add the above?

@harri.w.morgan,

Please use the below activities,

  1. Get Outlook Mail Messages to retrieve the mails
  2. For Each to iterate through each mail
  3. Use Assign and create a variable varMailDateTime and store the value
    varMailDateTime = item.Headers(“Date”).ToString
  4. Use Another variable and assign the value varConvertDateTime = DateTime.ParseExact(varMailDateTime, “MM/dd/yyyy HH:mm:ss”, CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Regards,
@90s_Developer