Solved

VBA Date

Posted on 2012-03-15
6
293 Views
Last Modified: 2012-03-19
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.
0
Comment
Question by:aneilg
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:macarrillo1
ID: 37724504
Your use of 'date' in

format(date,"yyyymmdd")

Is this a variable you created or a fieldname or the function date?
0
 
LVL 6

Expert Comment

by:Peter Kiprop
ID: 37724554
Hi aneilg,

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

Open in new window

0
 
LVL 9

Accepted Solution

by:
macarrillo1 earned 230 total points
ID: 37724576
You could also do:

        Dim strName As String
        Dim strDate as string

        strName = "test"
        strDate=format(date,"yyyymmdd")
        strName = strName & strDate
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:macarrillo1
ID: 37724621
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")
0
 

Author Comment

by:aneilg
ID: 37736947
thanks, perfect.
0
 

Author Closing Comment

by:aneilg
ID: 37736949
thanks, perfect.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now