Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
Date Formating
Logged in as: Guest
arrSession:exec spGetSession 2,2,59249
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> Date Formating
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
Date Formating -
4/17/2008 3:34:24 AM
¥TheApocalypse¥
Posts: 1
Score: 0
Joined: 4/16/2008
Status:
offline
Hi,
I getting started with vbscript, so I need some help
I'm trying to format or convert the system date to this "MM-dd-yyyy"
For example I do it in vba and it work.
here is what i have so far,
Dim filesys, dte, i, sourcefolder
Set filesys = CreateObject("Scripting.FileSystemObject")
Set sourcefolder = filesys.GetFolder("sourcefolder")
'dte = FormatDateTime((Date - 10), "MM-dd-yyyy")
dte = Date - 10
For i = dte To (Date - 1) Step 1
'i = FormatDateTime(i, "MM-dd-yyyy")
If Not filesys.fileexists(sourcefolder & "\" & i & ".xls") Then
MsgBox ("call other program and pass the following parameter (i & '.xls' )")
End If
Next
WScript.Quit
I'll appreciate your help.
Post #: 1
RE: Date Formating -
4/17/2008 9:40:35 PM
TomRiddle
Posts: 165
Score: 4
Joined: 2/7/2008
Status:
offline
You had a couple of errors in there.
Does this do the trick for you?
option explicit Dim sourcefolder, filesys, Days, i sourcefolder = "c:\scripts\test" Days = 10 Set filesys = CreateObject("Scripting.FileSystemObject") For i = 1 to days If Not filesys.fileexists(sourcefolder & "\" & MMDDYYYY(i) & ".xls") Then DemoSub MMDDYYYY(i) & ".xls" End If Next WScript.Quit '---------------------------------------------------------------------------- Function MMDDYYYY(input) Dim dte, MM, DD dte = Date - input if len(month(dte))=1 then MM = "0"&month(dte) else MM = month(dte) end if if len(day(dte))=1 then DD = "0"&day(dte) else DD = day(dte) end if MMDDYYYY = MM&"-"&DD&"-"&year(dte) End Function '---------------------------------------------------------------------------- sub DemoSub(input) msgbox input & " does not exist." end sub '----------------------------------------------------------------------------
< Message edited by
TomRiddle
--
4/17/2008 9:43:28 PM
>
(in reply to
¥TheApocalypse¥
)
Post #: 2
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> Date Formating
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI