The to_date() function seems to be working fine.
However the upper() function is not parsed correctly in the GROUPby clause. The following code from admin-community-view.tcl(line 73) was producing server errors when I was testing the Bboard system.
if { $n_postings < 2 } {
set sql "select distinct email, count(*) as how_many_posts
from bboard , users
where bboard.user_id = users.user_id
and topic_id = $topic_id
and posting_time >= to_date('$start_date','YYYY-MM-DD')
and posting_time <= to_date('$end_date','YYYY-MM-DD')
group by email
order by upper(email)"
} else {
set sql "select distinct email, count(*) as how_many_posts
from bboard, users
where topic_id = $topic_id
and posting_time >= to_date('$start_date','YYYY-MM-DD')
and posting_time <= to_date('$end_date','YYYY-MM-DD')
and bboard.user_id = users.user_id
group by email
having count(*) >= $n_postings
order by upper(email)"
}
set selection [ns_db select $db $sql]
The code dies at the set selection [ns_db select $db $sql] clause. If I remove the upper() functions it seems to work fine. I fired up the psql in emacs and found out that this $sql string was returning the error message:
ERROR: For SELECT DISTINCT, ORDER BY expressions must appear in target list
Is this a bug in my installation or in the code or in postgres?