Trying to use ad_form to set and get dates in postgres 7.2.3; it's setting it ok, but when it displays it in the edit form, it sets the values to 12:00 AM.
ad_form -name dealer_location_hours -export {location_id} -form {
location_hours_id:key(moto_location_hours_id_seq)
{day_begin:text(select) {label "Beginning Day"} {options {$day_options}}}
{day_end:text(select) {label "Ending Day"} {options {$day_options}}}
{time_open:date,to_sql(linear_date),from_sql(sql_date)
{label "Opening Time"}
{format "HH12:MI AM"}
{help}}
{time_close:date,to_sql(linear_date),from_sql(sql_date)
{label "Closing Time"}
{format "HH12:MI AM"}
{help}}
} -select_query {
select day_begin,
day_end,
to_char(time_open,'YYYY MM DD HH24 MI SS') as time_open,
to_char(time_close,'YYYY MM DD HH24 MI SS') as time_close
from moto_location_hours
where location_hours_id = :location_hours_id
} -validate {
} -new_data {
db_dml do_insert "
insert into moto_location_hours (
location_hours_id,
day_begin,
day_end,
time_open,
time_close,
location_id
) values (
:location_hours_id,
:day_begin,
:day_end,
to_timestamp(:time_open,'YYYY MM DD HH24 MI SS'),
to_timestamp(:time_close,'YYYY MM DD HH24 MI SS'),
:location_id
)"
}
moto=# select * from moto_location_hours;
location_hours_id | day_begin | day_end | time_open | time_close | location_id
-------------------+-----------+---------+---------------------+---------------------+-------------
22 | 2 | 5 | 0001-01-01 09:00 BC | 0001-01-01 19:00 BC | 12
(1 row)