Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting system date into MS Database 2

Status
Not open for further replies.

selaine

Programmer
Oct 11, 2001
85
US
I've created an asp page which contains a web site survey form. When the form is submitted, it does data validation and if everything is ok, inserts the record into the MS Access database. What I'd like to do, is at the time of submission, grab the system date (which is in short date format, as is the field in my database) and using a hidden field, insert the system date into the field along with the rest of the data. Does anyone know how I would do that? Thanks!
 
in the function that validates the form do this at the end
FMdate = new Date();
Curdate = (FMdate.getMonth()+1) +"/"+ FMdate.getDate() + "/" + FMdate.getYear()
document.form1.hidDate.value = Curdate;
//ouput 11/15/2002

in the form add
<input type=&quot;hidden&quot; name=&quot;hidDate&quot;>

then when the form is submitted and you run your validation script upon all conditions being passed you will add the value of the var Curdate to the hidden form field and pass it along with all the other fiedls

A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
I changed that to account for short date. sorry, forgot to add that spec in there.
FMdate = new Date();
var year = FMdate.getYear();
Curdate = (FMdate.getMonth()+1) +&quot;/&quot;+ FMdate.getDate() + &quot;/&quot; + (year+&quot;&quot;).substring(2,4);


hope that helps A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
The easy way to do this is to let the database do it.

The column in your table that has the date the survey is submitted can be given a default value using the Date function.

In your INSERT statement do not list the date column and do not insert a value. The database will supply the default value.

How to make the column use a default value:
Select the table and click on Design. Select the survey submitted date column. In the lower left area there is a bunch of stuff and one of the items under the General tab is Default Value. Type in Date(). Save the table. From now on whenever you insert a new row this column will have the date it was inserted.
 
see what happens when you get scripting happy. you forget the easiest things you learned a billion years ago. Very good suggestion rac2.
A star for reminding me things don't have to envolve code. ;)

A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top