Forums

ASP

This topic is locked

Date Question

Posted 24 Jul 2001 16:07:30
1
has voted
24 Jul 2001 16:07:30 troy hipolito posted:
Need to automaticaly upload the current "Date" each each time a new record is uploaded to an Access data base? I would think it would be a <input type="hidden" name="date" value="<%time()%>"> . Or somthing like that? If you can email me at Thanks

Replies

Replied 24 Jul 2001 17:14:01
24 Jul 2001 17:14:01 Viktor Farcic replied:
Easier way is to put default value in DB. If you're using Access put default value to 'Date()'. For SQL Server it's 'GetDate()'


<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Need to automaticaly upload the current "Date" each each time a new record is uploaded to an Access data base? I would think it would be a &lt;input type="hidden" name="date" value="&lt;%time()%&gt;"&gt; . Or somthing like that? If you can email me at Thanks


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replied 24 Jul 2001 19:15:33
24 Jul 2001 19:15:33 Bruno Mairlot replied:
The easiest way to do that is to use your database server handle the date.

Imagine your page has been open at 11:55 PM and the form is submitted at 0:34 PM, your date won't be correct.

So check your server documentation. I don't know which one you're using but in MySQL this would be now(). But in this case now() return a timestamp or a full description like 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.

So if you have datetime type, you can use it directly in your query.

If you have a date type, then use concat(),year(),month(),dayofmonth() to get the full date. It would give a query like :

insert into mytable (date) VALUES (concat(year(now()),'-',month(now()),'-',dayofmonth(now())))

But I think that what you really need is a timestamp. A timestamp is a time type that is modified every time a record is inserted or updated. It is set to the current time automatically without anything from you. Very useful. This is for MySQL, but I know it should work the same way on SQL Server and IBM DB2, I don't know for oracle but it should.

Bruno

Reply to this topic