?
Solved

Assign today's date to a variable using VB Script

Posted on 2014-03-04
3
Medium Priority
?
257 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 1200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

771 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