Solved

VBA Date

Posted on 2012-03-15
6
296 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 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

13 Experts available now in Live!

Get 1:1 Help Now