Solved

VBA Date

Posted on 2012-03-15
6
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

697 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