Assign Future Date


#1

Hello,

I am looking to assign a future date - specifically I am wanting to assign the date of a Monday 2 weeks in advance. For example if today is 10/8/2018, I need to display 10/22/2018.

Thank you for the support!
Mel


How to open a file folder of current year and then look for another folder with specific date
#2

Hi @melaniewatson,

You could use the following code:
DateTime today = DateTime.Today;
int daysUntilMonday = ((int)DayOfWeek.Monday - (int)today.DayOfWeek + 14);
DateTime nextMonday = today.AddDays(daysUntilMonday);


#3

I had to fix the typo in the subject line :rofl:


#4

Ha! The struggle is real sometimes - thanks for looking out :wink:


#5

If it’s any date and you just want to add 2weeks you can use system. DateTime.today.addDays(14)


#6

Hi @acaciomelo - Thank you for your response, but I am struggling to get the daysUntilMonday coded. Are you able to send a sample workbook? I must be missing something somewhere. Thanks again!


#7

@acaciomelo The error message I am getting is saying: ‘)’ is expected


#8

Slightly modify your expression : (CInt(DayOfWeek.Monday) - CInt(today.DayOfWeek) +14)
And check your variable type:


How to open a file folder of current year and then look for another folder with specific date
#9

Hi @nadim.warsi - When doing the assign activity for daysUntilMonday I am now getting an error that says the expression is not a member of ‘String.’ I have my variable type set at Int32. I even deleted it all and started from scratch, but I cant seem to figure out where I am going wrong.


#10

Hi @melaniewatson,

Please try the following code:

Dim today As DateTime = DateTime.Today
Dim daysUntilMonday As Integer = (CInt(DayOfWeek.Monday) - CInt(today.DayOfWeek) + 14)
Dim nextMonday As DateTime = today.AddDays(daysUntilMonday)

#11

Can you show me the other variables and their types that you have set?
Check my workflow on v18.3.0 futuredate.xaml (6.6 KB) which has the above logic


#12

I got it! I had the today variable set as string. Thanks for your help! :hugs:


#13

Great! :blush: