Solved

Assign today's date to a variable using VB Script

Posted on 2014-03-04
3
244 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 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

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

Suggested Solutions

Title # Comments Views Activity
delete a folder ever 5 minutes 6 60
VBA code shorten run time 4 53
Problem to open text file 11 68
Check folder every for files and print them 5 21
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 …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Send secure, cloud-based, encrypted alerts and maintain HIPAA compliant messaging. Integrates priority & secure messaging into one application. Ensures IT, emergency respondents and healthcare professionals that their critical messages are never mis…

911 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

21 Experts available now in Live!

Get 1:1 Help Now