445,705 Members | 1,829 Online
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
5 Replies

 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 If Me.Date1 > Me.Date2 And Me.Date1 > Me.Date3 Then Me.GreaterDate  = Me.Date1 If Me.Date2 > Me.Date1 And Me.Date2 > Me.Date3 Then Me.GreaterDate  = Me.Date2 If Me.Date3 > Me.Date1 And Me.Date3 > Me.Date2 Then Me.GreaterDate  = Me.Date3 If Me.Date1 = Me.Date2 And Me.Date2 = Me.Date3 Then Me.GreaterDate  = Me.Date1   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 If Me.Date1 > Me.Date2 And Me.Date1 > Me.Date3 Then Me.GreaterDate  = Me.Date1 If Me.Date2 > Me.Date1 And Me.Date2 > Me.Date3 Then Me.GreaterDate  = Me.Date2 If Me.Date3 > Me.Date1 And Me.Date3 > Me.Date2 Then Me.GreaterDate  = Me.Date3 If Me.Date1 = Me.Date2 And Me.Date2 = Me.Date3 Then Me.GreaterDate  = Me.Date1   Linq ;0)> Is Posible to create in the Query Column? Aug 7 '08 #3

 Expert Mod 15k+ P: 31,656 Try : Expand|Select|Wrap|Line Numbers 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

 Expert Mod 15k+ P: 31,656 Well, yes. The illustration is in my previous post :S Aug 8 '08 #6