> ... instead of date_trunc('day',sent_messages.date)
why don't you have a function that takes four three arguments: - beginning date of query - interval, ie, reminder_services.activity_days_min - timestamp, ie, sent_messages.date have it return the minimum date for that interval as I think I understand your problem, that should work __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate