472,106 Members | 1,251 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,106 software developers and data experts.

how to find the greatest date in a arry

chandru8
145 100+
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
2 1186
kadghar
1,295 Expert 1GB
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
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.

Similar topics

2 posts views Thread by zaceti | last post: by
8 posts views Thread by Mike Nolan | last post: by
2 posts views Thread by BB | last post: by
8 posts views Thread by Grey | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.