Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Date in Command Line 1

Status
Not open for further replies.

jessiejane

Programmer
Oct 29, 2009
32
US
I need to pass command line arguments in VB.NET.

The command line argument has current date appended to the filename. The date is in the format of MMDDYY.

Example: Test110709.txt

How would I code the date in this format(MMDDYY) in the command line.

Any help is greatly appreciated.
 
Use the Format function with a custom date format. Using today's date:

Code:
Dim sFileName As String

sFileName = "Test" & Format(Date.Today, "MMddyy") & ".txt"
Here's a link to the .NET custom date and time format strings:




I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
I have to pass in the command line i.e. command prompt the date.

Any help is appreciated.
 
jessiejane: I'm a little confused as what you're trying to do from where... The code provided by jebenson will give you a filename that matches your criteria based on today's date. you can then use that filename wherever you need it to.

If what you're saying is that you have a VB application that takes a command line parameter, and you want to find out from DOS how to generate that filename with the date, then it's a different story, which I'm not sure fits in this forum.

If what you're trying to achieve is read the filename that was provided on the command line, and figure out the date from it, then that can easily be done, you just need to ask for that.

If that's not what you were looking for, then I'm sorry, I'm afraid I have no idea what you're trying to do.



Cheers,

Realm174
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top