One approach to this task is to setup a hidden field (Insert > Form Objects > Hidden Field). Once the hidden field has been added, select the yellow icon that represents the hidden field and go to the Property inspector. In the Value field, enter the appropriate code for the date function:
ASP: <%= Date() %>
JSP: <%= new java.util.Date() %>
ColdFusion: #Now()#
If you want to give the user the option to change the date to something other than today's date, then use a regular text field instead of a hidden field.
When filling out the Insert Record server behavior dialog box, map the hidden form field to the date field in the database and set the data type to either "Date" or "MS Access Date".
Note: The date being inserted will be the date on the application server. Keep this in mind if users are in different time zones.
Setting the default value in the database
Another approach to this task is to set the default value of the database's date field to the current system date. Most, if not all, databases will have a "default value" option for database fields. One advantage to using this approach is that you do not have to worry about the date format being sent from the Web page. Here is how to set the default value to today's date in Microsoft Access 2000:
1 Open the database in Microsoft Access. This example uses the UltraDev 4 tutorial database, Compass Travel (compasstravel.mdb).
2 Open the appropriate database in Design View, and select the date field.
3 Go to the General tab in the bottom section of the window and type "Date()" (no quotes) in the Default Value field.
4 Save and close the database, and go back to UltraDev to finish the insert page.
5 When filling out the Insert Record server behavior dialog box in UltraDev, you will not map a form field to the date field in the database. The database will automatically fill in the current date when a new record is created.
Please refer to the Microsoft Access documentation for further detail on setting default values. If you are not using Access, please refer to your database documentation for instructions on how to set the default date value.
Note: The date being inserted will be the date on the database server. Keep this in mind if users are in different time zones.
+++++
***If you found my post or other's posts helpful - please let us know by clicking the helpful link below our posts.
Stuart