Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Compare dates

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1082
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Compare dates
  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 >>
 Compare dates - 6/23/2004 5:30:14 AM   
  bml104

 

Posts: 18
Score: 0
Joined: 3/9/2004
From:
Status: offline
I need to compare a date to another date
the format is 06/22/04 what would be the easy way to do this
the > dosent seem to work.
 
 
Post #: 1
 
 Re: Compare dates - 6/23/2004 6:15:05 AM   
  bml104

 

Posts: 18
Score: 0
Joined: 3/9/2004
From:
Status: offline
DaysOld = DateDiff("d", datemod , date)

got it.

(in reply to bml104)
 
 
Post #: 2
 
 Re: Compare dates - 6/24/2004 1:44:06 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Here is a script that I use to compare 2 dates and do something as needed.

Const WindowsFolder = 0
Const SystemFolder = 1
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")

Dim MyDate
MyDate = DateValue("7/17/2002 5:33:00 AM") ' Return a date.


If CompareFileDate(fso.GetFile(Fso.GetSpecialFolder(WindowsFolder) & "\help\hschelp.chm"), "7/17/2002 5:33:00 AM") = -1 then
Msgbox "nope"
Else
Msgbox "yup"
End if

Function CompareFileDate(Version1,Version2)
' Function returns -1 if Version1 < Version2
' Function returns 1 if Version1 > Version2
' Function returns 0 if Version1 = Version2

If DateValue(Version1.datelastmodified)<DateValue(Version2) then
CompareFileDate = -1
Exit Function
ElseIf DateValue(Version1.datelastmodified)>DateValue(Version2) then
CompareFileDate = 1
Exit Function
Else
CompareFileDate = 1
Exit Function
End if

End Function

(in reply to bml104)
 
 
Post #: 3
 
 
 
  

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 >> Compare dates Page: [1]
Jump to:





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