Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


find newest date out of several variables??

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> find newest date out of several variables??
  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 >>
 find newest date out of several variables?? - 9/8/2008 1:07:35 AM   
  mega128

 

Posts: 4
Score: 0
Joined: 12/8/2005
Status: offline
Hi all,

I am working on a script that should find the latest dates among several date values

value1 = CDate(value1) ' for example holds 9/4/2008 2:36:24 PM
value2 = CDate(value2) ' this var holds 9/2/2008 10:58:09 AM
value3 = CDate(value3) ' all variables below hold separate date values
value4 = CDate(value4)
value5 = CDate(value5)
value6 = CDate(value6)
value7 = CDate(value7)
value8 = CDate(value8)
value9 = CDate(value9)

If DateDiff("s", value1, value2,...) Then
???
End If

I am confused here, what kind of loop I have to run, that will probably call itself to check all variables and find the latest date?

I know it is little tricky but you Gurus out there may already have similar code snippet.

Thanks all for reading.
 
 
Post #: 1
 
 RE: find newest date out of several variables?? - 9/8/2008 1:32:34 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
How are you getting the initial dates?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to mega128)
 
 
Post #: 2
 
 RE: find newest date out of several variables?? - 9/8/2008 1:49:03 AM   
  mega128

 

Posts: 4
Score: 0
Joined: 12/8/2005
Status: offline
I am getting those off ADSI lastLogonTimestamp attribute.

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: find newest date out of several variables?? - 9/8/2008 2:02:37 AM   
  dm_4ever


Posts: 2669
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
I see...so you're trying to collect them and get the newest date.....

Well, I would add the dates to an array or dictionary to begin with....this way you can easily loop through the values and compare.  You should be able to find examples for both..

keywords:

Scripting.Dictionary
ReDim
Preserve

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to mega128)
 
 
Post #: 4
 
 RE: find newest date out of several variables?? - 9/8/2008 2:28:20 AM   
  mega128

 

Posts: 4
Score: 0
Joined: 12/8/2005
Status: offline
Yes, that's what I intend to do in future. I just wanted to get an idea what kind of loop should I run to get the newest date. That's why for now I have some temporary variables to play with.
But now it makes sense that I need to use array first.

Thanks

(in reply to dm_4ever)
 
 
Post #: 5
 
 
 
  

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 >> find newest date out of several variables?? 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