Min Date between 2 dates Predicate

Posts   
 
    
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 22-Apr-2009 03:54:13   

I have an object called AdmissionEncounter which has StartTime and EndTime fields. (both are DateTime) I have another object called PhysicalExam which has an ExamDate (DateTime)

There can be many PhysicalExams that occur between the StartTime and EndTime of the AdmissionEncounter.

I need to create a predicate to find the PhysicalExam with the ExamDate that is closest to the StartTime of the AdmissionEncounter.

i.e Min(PhysicalExam.ExamDate) where PhysicalExam.ExamDate between AdmissionEncounter.StartTime And AdmissionEncounter.EndTime.

Thanks

Billy Jacobs

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Apr-2009 05:48:09   

Hi Billy,

You could use FieldBetweenPredicate (more info). If you experiment problems please post the approximate sql filter you want to achieve wink

David Elizondo | LLBLGen Support Team
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 22-Apr-2009 15:50:07   

Right, but this will return multiple results and I want the one with the Min ExamDate.

I can loop through the results to find it, but I was wondering if there was some way I could use LLBLGen to return the 1 result.

Thanks,

Billy Jacobs

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Apr-2009 15:59:02   

To select a

Min(PhysicalExam.ExamDate)

use a Dynamic List with a Min Aggregate set to that field.

You can find a code sample at the above mentioned link.