Inserting Dates in Insert Form automatically
Insert current Date automatically in an Insert Form without you or a user having to do it for database Date field purposes be later used as a filter.
Using DMX Problem 1
I am trying to find out how to automatically insert Date in an Insert record - without the user knowing or having to it themselves, so as it appears in a date field in my database(Access), for that particular day.
Problem 2
Using the date as a filter in the Advanced recordist (query) what SQL can I use to a.delete records > 7 days old and b.to show me new records which have been inserted that are 2 days old.
I will be very grateful if you can point me in the right direction.
All the best!
Regards
Frank
Comments
Re: Inserting Dates in Insert Form automatically
You can use a hidden field. Put something like this in the value:
<%= Date() %>
or
<%= Day(Now) %>-<%= Month(Now) %>-<%= Year(Now) %>
Remember that this is the client date from the machine. Instead of using this client date (it can be set wrong by the client) use the server date.
So, you can also use Access to insert automaticly a date, the server date. Set the 'Date/Time' type of the field. Put in the 'Standardvalue':
Date()
and set the 'Notation' to for example 'Standard-datenotation'
RE: Inserting Dates in Insert Form automatically
The easiest route to follow would be to bypass coding at all and operate directly in Access. In your table, simply set the default value of your date field to "new Date()" (without the quotes), then whenever a new record is added to the table the date will be filled automatically.
The second problem is a bit more complex, using JScript you could try the following:
<%
var months="new" Array("January", "February", "March" ...etc.);
var d = new Date(((new Date()).getTime())-604800000);
var dstring = d.getDate()+" "+months[d.getMonth()]+" "+d.getFullYear();
var sqlstring = "DELETE * FROM [tablename] WHERE [datefield] < " + dstring + "";
%>
Finally, replace the SQL source in your Dreamweaver delete function with sqlstring.
If you're into VBScript then I can't really help. Because it's pants. ;)
RE: Re: Inserting Dates in Insert Form automatically
i want to use calender for date selection in vbscript code
You must me logged in to write a comment.