Regex date result convert from 23 May 2019 to 23/05/2019 + add 21 days to variable

Hi :slight_smile:

I have used regex to pull the date from the below Outlook email example:
“From: john@workplace.com
Sent: Thursday, 23 May 2019 7:11 AM
To: Team Inbox
Subject: Send me some more cookies”
:cookie:

Regex pattern used is:

  1. How does my regex pattern look? Any improvements/suggestions?
  2. Once I have pulled date field (eg, ‘23 May 2019’) - What is the easiest way to add 21 calendar days to this date in string format?

Example workflow attached:
Main.xaml (5.9 KB)

Any assistance would be appreciated :upside_down_face:

Kind regards

Steve

1 Like

Hi Steve

I don’t use Regex so can’t answer 1

but for 2 if it’s in a date format just use variablename.adddays(21).tostring(“dd/MM/yyyy”)

Hi @Steven_McKeering
well it looks great…
to add 21 days you can do like this with a assign activity
out_date_value = Datetime.Parseexact(DateString,“dd MMM yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(21)

where out_date_value is a variable of type datetime
else it looks good with your workflow,
Cheers @Steven_McKeering

1 Like

did that get resolved buddy @Steven_McKeering

Hello

Thanks for the response.

Unfortunately its in a string so I couldn’t get it to work.

can you come again with that
i didnt get you
Cheers @Steven_McKeering

out_date_value is a string for me.

So, ‘23 May 2019’ is in a string format.

1 Like

so you want the output as a string not datetime buddy
if so
its like this where create a variable out_date_value of type string
out_date_value = Datetime.Parseexact(DateString,“dd MMM yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(21).ToString(“dd MMM yyyy”)

Kindly correct me if still i have understood the query wrongly

Cheers @Steven_McKeering

you can use cdate(string) to convert it to a date format and then do the add days

out_date_value = Datetime.Parseexact(DateString,“dd MMM yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(21).ToString(“dd/MM/yyyy”)

its all the format that we mention while converting to string
you can mention any format you want
and for format guidance kindly have a view on this

Cheers

1 Like

Thanks @Palaniyappan

This solved it for me!

You were so helpful. I really appreciate the multiple responses! :100::clap:

For others - I also used this (it may also work):
Convert.ToDateTime(INSERTSTRINGDATEVARIABLE).AddDays(21).ToString(“dd/MM/yyyy”)

Regards

Steve

1 Like

No worries
Cheers buddy @Steven_McKeering
Keep going

1 Like

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