Change DateTime Format when sending outlook

Hello,

I’ve written a script in UiPath to automate sending of emails from data in an excel spreadsheet. For the email body, I’m using this dynamic formula to populate the date for the email [i.e under “Invoice Due”] - String.Format(EmailMessage,row(“Name”).ToString,row(“Invoice Due”).ToString)

When I run the script, I note in the email that the the date format is mm/dd/yyyy hh:mm:ss. How do I change the date format in the email sent to just “dd/mm/yyyy, Day (eg. Tuesday)”?

[The forum doesn’t allow me to add an attachment cos I’m a new user, so I can’t share the UiPath process…]

Thank you.

Hey @clarindapoh

If you’re just looking for the date format then it’ll be
YourString.ToString(“dd/MM/yyyy, dddd”)

Make sure month is represented by ‘MM’ not ‘mm’ (case sensitive)

Hi,

Thanks for your reply. I’ve tried amending to “String.Format(EmailMessage,row(“Name”).ToString,row(“Invoice No”).ToString,row(“Invoice Due”).ToString(“dd/MM/yyyy, dddd”)”, but there’s an error in this script. How can I fix it?

Hi @clarindapoh

Please try like this

row(“Invoice Due”).ToString(“dd/MM/yyyy) + “, " + row(“Invoice Due”).ToString(“dddd”)

Thanks

Hi @clarindapoh

Maybe the data column of your data table didn’t recognized the column type correctly.

Convert to date time before using the .ToString method.

 Date.Parse(row("Invoice Due").ToString).ToString("dd/MM/yyyy, dddd")