I don't think this will work too well for birthdays because the year is
irrelevant, it should only use the day & month.

Paul

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Berryl Hesh
Sent: 22 March 2010 22:55
To: nhusers
Subject: [nhusers] Re: query on dates

Here's a query I did recently for a similar problem:

public IEnumerable<Allocation> FetchAllocationsFor(Resource resource,
DateRange range)
        {

            const string hql_allocations =
                @"SELECT a FROM Resource r JOIN r.Allocations a " +
                "WHERE a.Resource = :resource " +
                "AND a.TimeRange.StartTime between :start and :end";

            return
_sessionFactory.GetCurrentSession().CreateQuery(hql_allocations)
                .SetParameter("resource", resource)
                .SetDateTime("start", range.Start)
                .SetDateTime("end", range.End)
                .Future<Allocation>();
        }

The DateRange param has nothing to do with NHib, but is useful in my
domain. It does mean you'd have to calculate the 30 day later end
point outside of your query though. If I remember correctly the NHib
between range is inclusive of the end points.

HTH,
Berryl

-- 
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.


No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.791 / Virus Database: 271.1.1/2759 - Release Date: 03/22/10
07:33:00


-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to