Avatar of aneilg
aneilgFlag for United Kingdom of Great Britain and Northern Ireland asked on

VBA Date

i am using vba script to get the date in the following format.
YYYMMDD

when i use
        Dim strName As String

        strName = "test"
        strName = strName & format(date,"yyyymmdd")

on the date section i get 'of' required when specifying type argument.
VB Script

Avatar of undefined
Last Comment
aneilg

8/22/2022 - Mon
Michael Carrillo

Your use of 'date' in

format(date,"yyyymmdd")

Is this a variable you created or a fieldname or the function date?
Peter Kiprop

Hi aneilg,

The below should work
 Dim strName As String
 strName = Format(Date, "yyyymmdd")

Open in new window

ASKER CERTIFIED SOLUTION
Michael Carrillo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Michael Carrillo

If you are trying to pull the current date you should use the date function: Date()

        Dim strName As String

        strName = "test"
        strName = strName & Format(Date(),"yyyymmdd")
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
aneilg

thanks, perfect.
ASKER
aneilg

thanks, perfect.