Forum Discussion

DCat1223's avatar
DCat1223
Frequent Contributor
3 years ago

Formatting a date in a Code Snippet

Hello.  I have a test script where I need to input the week beginning date in a date field.  The format of the date field is mmddyyyy.

I am using this code snippet:

(Date-WEEKDAY(Date())+1)

The issue I am running into is today is May 3, 2022 and week beginning date, May 1, 2022 is entered as 512022 (mdyyyy), not 05012022 (mmddyyyy).

 

What is the syntax to format this as mmddyyyy using VBA?  

 

I am not concerned about date separators.  Just having the date display as 05012022.

 

Thanks in advance!