Solved

Assign today's date to a variable using VB Script

Posted on 2014-03-04
3
255 Views
Last Modified: 2014-03-04
Experts,

I have a VB script that i am currently running to copy files from one folder to another. I would like to assign today's date to  variable tday.

I would then like to make a concatatenated variable of the date to be:

YYMMDD   thus today would be 140304

How would I do this in my script.

 I am having a problem just assigning today's date for some reason.  I am running in Windows 7.
0
Comment
Question by:morinia
[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 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39904081
Try this:
strDate = Format(Date, "YYMMDD")

Open in new window

0
 

Author Comment

by:morinia
ID: 39904105
This gives me a type format error
0
 
LVL 58

Accepted Solution

by:
Gary earned 300 total points
ID: 39904131
tday = year(date) & Right(String(2, "0") & Month(date), 2) & Right(String(2, "0") & Day(date), 2)

Open in new window

0

Featured Post

Independent Software Vendors: 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!

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 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