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

Hello, I tried to use the foll

Status
Not open for further replies.

wuwang

Programmer
May 16, 2001
48
US
Hello,


I tried to use the following code (from EXCEL to text file)
to add system time (eastern time) as part of my .txt file name. So the file name should be
Update_testfile3_systemtime.txt

Open ThisWorkbook.Path & "\Update_testfile3" & Now - Int(Now) & ".txt" For Output As #1


But the output is like -
Update_testfile30.575925925928459.txt

I have no idea about these numbers. If it is possible to have the systemtime output like ddmmyysh (s means second, h means hour)?
 
Hi,
Try Now instead of
... Now - int(Now)
To have ddmmyysh use the Format() statement

Jon
 
Use this instead

Code:
Open ThisWorkbook.Path & "\Update_testfile3" & Format(Now(), "ddmmyySh") & ".txt" For Output As #1

you will get a filename like
Update_testfile32901024911.txt Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Now returns a number which represents the date and time. When you subract Int(Now()) from Now(), what you are doing is returning the value of Now() to the right of the decimal place, which does represent the time, but in your case it as a fraction. What you need is something like :

Open ThisWorkbook.Path & "\Update_testfile3" & Format(Now, "hh:mm:ss") & ".txt"

Format(Now, "hh:mm:ss") returns the current time as a String. You could also include mm/dd/yy etc.

Hope that helps you out.

 
Thanks guys.

I hope you don't mind I have more questions about this issue.
What's the meaning of 3(the first digit) from the output : "Update_testfile32901024911.txt"
Is it possible to avoid the "3"?

Besides, if there is a function to force the time with East time? The reason is my customers from different places use the EXCEL file I create and send in their reports to one common place. I will have these report run automaticlly in a certain time at midnight.
And it is easier if all the reports send in with standard East time.

Is it possible? Thanks for your help.






 
Very sorry to confuse you. Please disregard about my
first question about the digit "3".
A typo in my code.
 
Hi,

Here's a thread on how to get the time zone of a given computer. From there you can adjust the time/date stamp

thread222-200177
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top