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

Multiple Date field and Obtain the Maximun Date

P: 36
Hello People!

I have 3 fields dates. Example: Date1, Date2 and Date3. I don't know how obtain in this 3 fields the greater date.

Ex:

If Date1 = 01/01/08 and Date2 = 01/02/08 and Date3 = 01/03/08

then the field show [Date3].

These fields are for a data entry and the query I made most show for these fields the maximun date field.

Any One!!!

Thanks!!
Aug 7 '08 #1
Share this Question
Share on Google+
5 Replies


missinglinq
Expert 2.5K+
P: 3,532
This should properly be done with a Bubble Sort, but I haven't done one in decades and am too lazy to figure it out! Sorry! But with only three elements to sort, it's simple to do with four If statements. Sorry!
Expand|Select|Wrap|Line Numbers
  1. If Me.Date1 > Me.Date2 And Me.Date1 > Me.Date3 Then Me.GreaterDate  = Me.Date1
  2. If Me.Date2 > Me.Date1 And Me.Date2 > Me.Date3 Then Me.GreaterDate  = Me.Date2
  3. If Me.Date3 > Me.Date1 And Me.Date3 > Me.Date2 Then Me.GreaterDate  = Me.Date3
  4. If Me.Date1 = Me.Date2 And Me.Date2 = Me.Date3 Then Me.GreaterDate  = Me.Date1
  5.  
Linq ;0)>
Aug 7 '08 #2

P: 36
This should properly be done with a Bubble Sort, but I haven't done one in decades and am too lazy to figure it out! Sorry! But with only three elements to sort, it's simple to do with four If statements. Sorry!
Expand|Select|Wrap|Line Numbers
  1. If Me.Date1 > Me.Date2 And Me.Date1 > Me.Date3 Then Me.GreaterDate  = Me.Date1
  2. If Me.Date2 > Me.Date1 And Me.Date2 > Me.Date3 Then Me.GreaterDate  = Me.Date2
  3. If Me.Date3 > Me.Date1 And Me.Date3 > Me.Date2 Then Me.GreaterDate  = Me.Date3
  4. If Me.Date1 = Me.Date2 And Me.Date2 = Me.Date3 Then Me.GreaterDate  = Me.Date1
  5.  
Linq ;0)>
Is Posible to create in the Query Column?
Aug 7 '08 #3

NeoPa
Expert Mod 15k+
P: 31,656
Try :
Expand|Select|Wrap|Line Numbers
  1. Latest:IIf([Date1]>[Date2],IIf([Date1]>[Date3],[Date1],[Date3]),IIf([Date2]>[Date3],[Date2],[Date3]))
Aug 7 '08 #4

P: 36
So, it's possible to put these fields in one in a query and show the greater date?
Aug 8 '08 #5

NeoPa
Expert Mod 15k+
P: 31,656
Well, yes.

The illustration is in my previous post :S
Aug 8 '08 #6

Post your reply

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