How to output a date that is 2 days ahead of today's date but it excludes weekend days in a text format?

Hello,

Hope someone can help. as topic header states, is it possible to output a date 2 days ahead of today’s date but exludes weekend days I.E date is 07/08/2020 (last friday) and you wanted to display the date that would be 2 days ahead BUT doesn’t include weekend days so - 11/08/2020 (Tuesday) in a text format?

Is this possible?

Thanks

1 Like

Well this now.ToString("ddd-MM-yyyy") will give you, Sun-08-2020

There’s really a lot of ways to do this, check Microsoft .NET DateTime formats. anyways you can use an if to check if Not DateVar_Str.Contains("Sat") Or Not DateVar_Str.Contains("Sun")

and then convert date back to what you want and use the AddDays(2) function get two days ahead. for example: this now.AddDays(2).ToString("ddd-MM-yyyy") will give you Tue-08-2020

and

now.AddDays(2).ToString("dddd") = Tuesday

2 Likes

Hi Senzo,

That’s a good example of what i’m after thank you!

One question I have.

My knowledge is very limited regarding this so, could you provide an example of how i would set the date as the now.ToString(“ddd-MM-yyyy”), create the If statement excluding Sat and Sun. and then convert it to the date format that I want, that is dd/mm/yyyy (09/08/2020 as example)?

Thank you.

@JayBee

Test_date.xaml (5.2 KB)

1 Like

This is perfect.

Thank you so much for your help @SenzoD.

Really appreciated.

All the best.

1 Like

anytime man, glad i could help

Hi @SenzoD

Sorry i’m back again, just notice something regarding this and i have another question.

I missed something out from my original post so I do apologizes for that.

i’ll provide some context so you may better understand what i’m trying to achieve.

I need to input a delivery date into a text field for a customer. and each customer has a different lead time (24 hour delivery, 48 hour delivery, 72 hour delivery, 2 weeks, 4 weeks, etc).

so the solution you’ve given me is definitely on the right tracks for what i’m after, but i noticed that for instance, if i put in an order on say like friday the 7th for an example, on a 24 hour delivery(so 1 day).

I need it to go to the next working week day (monday) rather than the saturday it would naturally fall on.

Does this make sense? sorry i wasn’t more clear in my initial post.

Do you have any idea how could achieve this?

Thank you.

Test_date.xaml (6.5 KB)
Please see whether it fulfills your requirement.

Hi @Madeshwaran_Mohanraj

That is so close to what i’m after! thank you.

just one question, the format you’ve provided does it mm/dd/yyyy. how do i change it to add the day value like this - dd/mm/yyyy?

Thank you.

Use this function to convert Convert.ToDateTime(DateTime.ParseExact(“07/08/2020”,“dd/MM/yyyy”,CultureInfo.InvariantCulture))

replace your date with “07/08/2020”

Import System.Globalization in your importsTest_date.xaml (5.2 KB)

@Madeshwaran_Mohanraj

Just downloaded and tested your .xaml file but it still reads the date as MM/dd/yyyy

Sorry i’m not massively knowledgeable on this. is there something i need to edit for it to change the format?

Thanks

Hi,

Not sure if anyone could look into my last question or help with an answer?

Everything i’ve looked at to solve it hasn’t come with success.

The day addition that @Madeshwaran_Mohanraj provided works great.

But the format still prints as MM/dd/YYYY when i need it to be GB’s dd/MM/yyyy.

image

image

Thanks