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

Convert date format to text for file name

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
520
US
Hi all,

For the life of me I can not remember how to convert a date from this 02/01/2010 to this 02012010. The application is for saving a file name.

The date is pulled from: Me.Ship_Date

How can I make the conversion?
Code:
objXLBook.SaveAs ("E:\path\" & Me.First_Name.Value & " " & Me.Last_Name.Value & " " &  Me.Ship_Date.Value " - Package List Form" & ".xlsx")
Thank you for all the help!
 
Have a look at the Format function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried this, but I am not familiar with the format function and know that I am doing something wrong. Can you point me towards the right direction?

Code:
bob = Format(Me.Order_Date, , mmddyyyy)
 
Here is an update. I read through allot of posts, very informative by the way, and I was able to see my error. The corrected code now looks like this.

Code:
bob = Format(Me.Order_Date, "mmddyyyy")

This now outputs the correct format, but if the month or day is a single digit, it does not output all 8 characters. For instance:

02/10/2009 = 2102009
10/01/2009 = 1012009

what I would like to happen is:

02/10/2009 = 02102009
10/01/2009 = 10012009

what am I missing in my code?

Thank you for the help!
 
{i]what am I missing in my code?[/i]
Which code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV thank you for the reply, the function was working, but I was outputting into a excel cell to check the output which caused the error with the 0 being dropped.

I do have a new question, here is the code so far:

Code:
'Save Excel File Operations

bob = Format(Me.Order_Date, "mmddyyyy")
NEWFILENAME = "E:\file path\" & Me.First_Name.Value & " " & Me.Last_Name.Value & " " & bob & " - Package List Form" & ".xlsx"

objXLBook.SaveAs (NEWFILENAME)

What I would like to do is place the excel file that is generated into an attachment field called [Packaging List]

what is the function to make the field equal to NEWFILENAME?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top