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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Padding shortdate single digit values 1

Status
Not open for further replies.

MorganGreylock

Programmer
Jan 30, 2001
223
US
I'm trying to get some columns to all line up, and instead of trying to calculate the length of the date and insert an appropriate number of spaces, I'd rather see if theres a way I can force this date:

4/5/2005

to appear like this:

04/05/2005

So that every value on each line will have the same length, making all my columns line up nicely. Is there a relatively easy way of doing this? I didn't want to go through the trouble of checking each value < 10 or whatever, but I can if necessary.

Thanks in advance
 
And this date...is it a date value or a string value?. How are you displaying the data?...in a grid, in textboxes?

Sweep
...if it works dont f*** with it
...if its f****ed blame someone else
...if its your fault that its f***ed, say and admit nothing.
 
Its being output to a text file.

Code:
LastModDate = FormatDateTime(File.GetLastWriteTime(root), DateFormat.ShortDate)
Is what I've got now.
 
Here's the old VB6 way:
Code:
dim sDate as string = Format(file.getlastwritetime(root),"MM/dd/yyyy")

Still works in .Net. Date.ToString is also supposed to support a format parameter.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top