Gossamer Forum
Home : Products : Links 2.0 : Customization :

Building a date from 3 variables

Quote Reply
Building a date from 3 variables
Hello,

I have added some new fields to links.def (StartMonth, StartDay, StartYear) so that people may select a starting date for events that will be listed within the database. The select fields correctly display using the build_select_field, and they are written correctly to the database.

My question is, how can I take these three separate variables and combine it into one DATE variable like "StartDate" (ie. 15-Jan-2000), and then write it to the links.db as this new field so that it can be used as part of a search.

I suppose this isn't crucial, because I can just use the variables I have right now, but if anyone has any suggestions or sees an easier way to do this, please let me know! Thanks.


Quote Reply
Re: Building a date from 3 variables In reply to
In sub process_form, add.cgi right after this code:
Code:
# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;
add code similar to the following:
Code:
# Set StartDate based on StartMonth, StartDay, and StartYear
$in{$db_cols[$db_startdate]} =
$in{$db_cols[$db_startday]} . "-" .
$in{$db_cols[$db_startmonth]} . "-" .
$in{$db_cols[$db_startyear]};
This assumes that StartDate is defined in links.def and the variables, $db_startdate, $db_startday, $db_startmonth, and $db_startyear are also all defined in links.def and point to the corresponding field numbers of the record.

I hope this helps.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/