Smart questions
Smart answers
Smart people

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

VBScript FAQ


How do I create a text file using the date?
Posted: 27 Jan 04 (Edited 27 Jan 04)

After searching through the group and a little tinkering, I came up with this that allows you to create a file with the date.  The format is such as it will be easier to find in a folder later YYMMDD.

Hope this helps someone! Thanks to those who helped me.

' ********************************************
' * Script Name: FileandDate.vbs             *
' * Author: TD 9343                          *
' * Address:                                  *
' * Created: 26/01/04                        *
' ********************************************

' **** Perform script initialization here ****

Option Explicit

On Error Resume Next

Dim fsoObject, open_File, target_File, thisday
Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject")

' ********* Main processing section **********

' ### call function to get the date ###

' ### set the file name to include the variable from the process above
target_File = "C:\temp\vb\" & thisday & ".txt"

' ### open the file and put a header on the page ###

open_File.WriteLine "*******************************************"
open_File.WriteLine "* Daily Checks for: " & date & ".           *"
open_File.WriteLine "* Run at: " & time & ".                       *"
open_File.WriteLine "* This file is named: " & thisday & ".txt          *"
open_File.writeline "*******************************************"
open_File.WriteLine " "


' *********** Procedures go here *************
' ### This function opens a file ###

Function Open_My_File()

  If (fsoObject.FileExists(target_File)) Then
    Set open_File = fsoObject.OpenTextFile(target_File, 8)
    Set open_File = fsoObject.OpenTextFile(target_File, 2, "True")
  End If

End Function
' ***************************************************************

' ***************************************************************
' ### This function closes a file ###

Function Close_My_File()

End Function
' ***************************************************************
' ***************************************************************
' ### This funtion gets the date in format yymmdd ###
Function Today_Date()

thisday=Right(Year(Date),2) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2)

End Function
' ***************************************************************

Back to VBScript FAQ Index
Back to VBScript Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close