0
Help please !! Need to insert date automatically in form

/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/td-p/685710
Jan 22, 2007
Jan 22, 2007
Copy link to clipboard
Copied
I have been trying unsuccessfully for a week to automatically
capture today's date on a form. I can display a date on screen but
it will not insert date into mySQL db. All other information is
inserted as expected.
Am I just whistling in dark? Is there no way to eliminate user input for the order date field?
I have looked throughout the forums and no luck.
Anyone have any ideas about how to do?
Thanks,
Dale 🙂
Am I just whistling in dark? Is there no way to eliminate user input for the order date field?
I have looked throughout the forums and no luck.
Anyone have any ideas about how to do?
Thanks,
Dale 🙂
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/m-p/685711#M186155
Jan 22, 2007
Jan 22, 2007
Copy link to clipboard
Copied
In the database itself, you can have it automatically do
this. I'm not
very familiar with mySQL but in MS SQL, you just do (getdate()) in the
default field. I would suspect that mySQL is similar.
Dale60 wrote:
> I have been trying unsuccessfully for a week to automatically capture today's
> date on a form. I can display a date on screen but it will not insert date into
> mySQL db. All other information is inserted as expected.
> Am I just whistling in dark? Is there no way to eliminate user input for the
> order date field?
> I have looked throughout the forums and no luck.
> Anyone have any ideas about how to do?
> Thanks,
> Dale :-)
>
very familiar with mySQL but in MS SQL, you just do (getdate()) in the
default field. I would suspect that mySQL is similar.
Dale60 wrote:
> I have been trying unsuccessfully for a week to automatically capture today's
> date on a form. I can display a date on screen but it will not insert date into
> mySQL db. All other information is inserted as expected.
> Am I just whistling in dark? Is there no way to eliminate user input for the
> order date field?
> I have looked throughout the forums and no luck.
> Anyone have any ideas about how to do?
> Thanks,
> Dale :-)
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/m-p/685712#M186156
Jan 22, 2007
Jan 22, 2007
Copy link to clipboard
Copied
Dale60 wrote:
> I have been trying unsuccessfully for a week to automatically capture today's
> date on a form. I can display a date on screen but it will not insert date into
> mySQL db. All other information is inserted as expected.
> Am I just whistling in dark? Is there no way to eliminate user input for the
> order date field?
> I have looked throughout the forums and no luck.
> Anyone have any ideas about how to do?
INSERT INTO TABLE (col1,col2,... yourdatecolumn)
VALUES ("foo","bar",... NOW())
Mick
> I have been trying unsuccessfully for a week to automatically capture today's
> date on a form. I can display a date on screen but it will not insert date into
> mySQL db. All other information is inserted as expected.
> Am I just whistling in dark? Is there no way to eliminate user input for the
> order date field?
> I have looked throughout the forums and no luck.
> Anyone have any ideas about how to do?
INSERT INTO TABLE (col1,col2,... yourdatecolumn)
VALUES ("foo","bar",... NOW())
Mick
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/m-p/685713#M186157
Jan 23, 2007
Jan 23, 2007
Copy link to clipboard
Copied
Thanks to you both for your replies. My server was down so
could not get on these until now. I have tried both but neither
works. Here is my code snippet from with Dreamweaver. Maybe this
will help provide answwer. I tried both NOW() and CURTIME(). In my
database the $order_date is a DATE field.:
$insertSQL = sprintf("INSERT INTO `Order_Master(email, acct_no, order_date, item_id, Qty, UM, TransType, comments, when_done) VALUES ('$email', '$acct_no', CURTIME(), '$item_id', '$Qty', '$UM', '$TransType', '$comments', NOW())");
Let me know what you think. I've tried so many approaches my fingers are wearing out.!! Thanks,
Dale:
$insertSQL = sprintf("INSERT INTO `Order_Master(email, acct_no, order_date, item_id, Qty, UM, TransType, comments, when_done) VALUES ('$email', '$acct_no', CURTIME(), '$item_id', '$Qty', '$UM', '$TransType', '$comments', NOW())");
Let me know what you think. I've tried so many approaches my fingers are wearing out.!! Thanks,
Dale:
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/m-p/685714#M186158
Jan 24, 2007
Jan 24, 2007
Copy link to clipboard
Copied
With setting a default value, in MS SQL, I have to tell it
not to accept
nulls to force it to set the default.
Again, not all that familiar with mysql. I can look it up at home to see.
http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
This may help...not sure because it's been about a year since I've done
anything with mysql
nulls to force it to set the default.
Again, not all that familiar with mysql. I can look it up at home to see.
http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html
This may help...not sure because it's been about a year since I've done
anything with mysql
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/m-p/685715#M186159
Jan 30, 2007
Jan 30, 2007
Copy link to clipboard
Copied
You can use a timestamp function within your MySQL table, but
remember you can only use the timestamp function ONCE in a table.
Using the timestamp Function:
Set the field type to TIMESTAMP. You can also set the default to CURRENT_TIMESTAMP and the attributes to ON UPDATE CURRENT_TIMESTAMP if you want the timestamp to change when the record is updated.
If you want to record times more than the one time you are using the timestamp and you are using PHP/MySQL or PHP/MySQL ADODB (InterAKT's PhAKT Extension), then try this:
http://chuckomalley.net/help/insert_date_help.php
That gets the time into the MySQL Database. Next thing you'll want to do is to have it display the time the way you want it. The default will display it as yyyy-mm-dd hh:mm:ss and you may not want it that way. To display it the way you want it try this:
http://chuckomalley.net/help/display_formatted_date.php
For the specific syntax on using this, refer to the online MySQL Manual and search for DATE_FORMAT() at http://dev.mysql.com/doc/mysql/en/index.html
Cheers
Chuck
Using the timestamp Function:
Set the field type to TIMESTAMP. You can also set the default to CURRENT_TIMESTAMP and the attributes to ON UPDATE CURRENT_TIMESTAMP if you want the timestamp to change when the record is updated.
If you want to record times more than the one time you are using the timestamp and you are using PHP/MySQL or PHP/MySQL ADODB (InterAKT's PhAKT Extension), then try this:
http://chuckomalley.net/help/insert_date_help.php
That gets the time into the MySQL Database. Next thing you'll want to do is to have it display the time the way you want it. The default will display it as yyyy-mm-dd hh:mm:ss and you may not want it that way. To display it the way you want it try this:
http://chuckomalley.net/help/display_formatted_date.php
For the specific syntax on using this, refer to the online MySQL Manual and search for DATE_FORMAT() at http://dev.mysql.com/doc/mysql/en/index.html
Cheers
Chuck
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
LATEST
/t5/dreamweaver-discussions/help-please-need-to-insert-date-automatically-in-form/m-p/685716#M186160
Jan 31, 2007
Jan 31, 2007
Copy link to clipboard
Copied
I use PHP and dates in MySQL are a real pain!
I also have simlar issues and have found that you can use the MyPHPAdmin to set one (one only) field to timestamp and automatically change to Now() when updated (as discussed above)
But I wanted another field to keep the original create date - similar to your order date.
This is what I did.
Changed the format of the column to datetime
Created a hidden field within my form
<input name="WHATEVER" type="hidden" id="WHATEVER" value="<?php echo date("Y-m-d H:i:s"); ?>">
This automatically generates the equivalent of a Now() statement.
Then just include it as a date value in your update or insert statement
GetSQLValueString($HTTP_POST_VARS['CREATED'], "date")
I also have simlar issues and have found that you can use the MyPHPAdmin to set one (one only) field to timestamp and automatically change to Now() when updated (as discussed above)
But I wanted another field to keep the original create date - similar to your order date.
This is what I did.
Changed the format of the column to datetime
Created a hidden field within my form
<input name="WHATEVER" type="hidden" id="WHATEVER" value="<?php echo date("Y-m-d H:i:s"); ?>">
This automatically generates the equivalent of a Now() statement.
Then just include it as a date value in your update or insert statement
GetSQLValueString($HTTP_POST_VARS['CREATED'], "date")
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

