Forum OpenACS Q&A: Date Math with bind variable emulation in postgresql

In file-storage/www/file-storage-procs-postgresl.xql is this query:
    <fullquery name="fs::get_folder_contents.select_folder_contents">
        <querytext>
            select fc.*
            from (select fs_objects.object_id,
                         fs_objects.name,
                         fs_objects.live_revision,
                         fs_objects.type,
                         to_char(fs_objects.last_modified, 'Month DD
YYYY HH24:MI') as last_modified,
                         fs_objects.content_size,
                         fs_objects.url,
                         fs_objects.key,
                         fs_objects.sort_key,
                         case when fs_objects.last_modified >= (now()
- $n_past_days) then 1 else 0 end as new_p,
                        
acs_permission__permission_p(fs_objects.object_id, :user_id, 'admin')
as admin_p,
                        
acs_permission__permission_p(fs_objects.object_id, :user_id, 'delete')
as delete_p,
                        
acs_permission__permission_p(fs_objects.object_id, :user_id, 'write')
as write_p
                  from fs_objects
                  where fs_objects.parent_id = :folder_id) fc
            where 't' = (select
acs_permission__permission_p(fc.object_id, :user_id, 'read') from dual)
            order by fc.sort_key,
                     fc.name
        </querytext>
    </fullquery>
the now()-:n_past_days is breaking. The bind variable emulation in the postgresql driver adds single-quotes around the n_past_days variable resulting in the following expression:
now() - '-1' 
Postgresql thinks that the integer inside the quotes is a date to subtract and returns an error "ERROR: Bad timestamp external representation '-1'".
I changed the :n_past_days reference to $n_past_days.
I think this is a reasonable solution. The n_past_days variable is checked by ad_page_contract to ensure it is an integer. If we know the input is an integer it should be safe to pass it directly in to the query.
Am I missing anything?
I'm fine with it ...
There should be a comment in the code explaining why, though, otherwise some sharp-eyed reader will come along, change it back, and commit it.
Alternatively, you could say

now() - interval(:the_interval)

where the_interval is '1 days' or similar.

Of course, then you have to change the code somewhat, too.

In my experience trying to keep the Oracle and PG code to look as much like each other as possible, it's easier to keep the integer day different paradigm rather than use interval this way.

When I've written PG-only stuff I've always used the interval notation, however.