By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

how to find the greatest date in a arry

chandru8
100+
P: 145
hi to all
iam having dates in array (dd/mm/yy)
i need to find the greatest date value from the array
ex
array(1) = 01/01/2003
array(2) = 01/03/2003
array(3) = 01/05/2003
array(4) = 02/02/2004
array(5) = 01/01/2003
array(6) = 03/04/2008


the highest value is 03/04/2008


can any one help me
its vvvery urgent
please
Jun 24 '08 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
sure

make the array a DATE array, then you can use (depending on the version) a math.max() function, or create it by yourself, e.g.

Expand|Select|Wrap|Line Numbers
  1. dim arr1(1 to 10) as date
  2. 'here's the code where you fill the dates into the array
  3. dim i as integer
  4. dim tmp1 as date
  5.  
  6. tmp1=arr1(1)
  7. for i = 2 to 10
  8.     if arr1(i) > tmp1 then tmp1=arr1(i)
  9. next
  10. msgbox tmp1
HTH
Jun 24 '08 #2

P: 1
if youre using proper date objects, try sorting ascending, and the last item is your highest:

Expand|Select|Wrap|Line Numbers
  1. ' sort the date array
  2. Array.Sort(dates)
  3.  
  4. ' your highest date will be:
  5. dates(dates.GetUpperBound(0))
  6.  
  7. ' your lowest date will be:
  8. dates(0)
  9.  
Jun 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.