1.

Solve : VB script help needed?

Answer»

Hi all, sorry if this is something simple, but...

I am TRYING to modify a VB script and change the line where it creates a log file. I want to add to the end of the name some sort of date/time stamp. Example: outputlog.txt would become outputlog.04032009.txt -or- outputlog.09111.txt the last one is YR/Julian day.

Any help is appreciated, thanks in advance.Files already have time stamps, so why do you need this?
Do you want just the date? CREATION date? Modify Date?
What does 09111 mean? In that Jan 11, 2009 ?
Do you have a BIT of the VB script that opens the log file?

You might be able to use:
Code: [Select]logfilename = "outputlog." & Replace( CStr( Date ), "/", "" ) & ".txt"NOTE: Replace "/" with your date separator character. Quote from: Geek-9pm on April 03, 2009, 03:21:19 PM

What does 09111 mean? In that Jan 11, 2009 ?

Quote
09111.txt the last one is YR/Julian day.

I'm a bit confused here. The Julian date (JD) is the interval of time in days and fractions of a day, since January 1, 4713 BC. The Julian date for CE 2009 April 4 00:00:00.0 UT is JD 2454925.50000

Julian date is sometimes used as a synonym for day of year, but this is not correct usage. Day of year ranges from 1 to 365 (366 for leap years). Today's day of year (4th April 2009) is 94.

So where did the 09111 come from?

Here is some date & time stamp vbs code

Code: [Select]
Dim dd,mm,yy,YYYY,DateStamp,FileName,DayOfYear,DoYstamp

dd=Day(Date)
mm=Month(Date)
yyyy=Year(Date)
yy=Mid(yyyy,3,2)
DayOfYear=(DatePart("y",Date))

If dd<10 Then dd="0"&dd
If mm<10 Then mm="0"&mm

If DayOfYear<10 Then DayOfYear="0"&DayOfYear
If DayOfYear<100 Then DayOfYear="0"&DayOfYear

DateStamp=mm&dd&yyyy
wscript.echo "Datestamp "&DateStamp
FileName="outputlog."&DateStamp&".txt"
wscript.echo "Filename "&FileName

DoYstamp=DayOfYear&yy
wscript.echo "DoYstamp "&DoYstamp
FileName="outputlog."&DoYstamp&".txt"
wscript.echo "Filename "&FileName




Thanks all. This is what I needed. I do appreciate the help.


Discussion

No Comment Found