Solved

Assign today's date to a variable using VB Script

Posted on 2014-03-04
3
243 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
3 Comments
 
LVL 26

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

12 Experts available now in Live!

Get 1:1 Help Now