close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

insert current date

Thread began 5/02/2010 10:12 pm by keith298718 | Last modified 5/07/2010 5:52 pm by Jimmy Wu | 2342 views | 6 replies |

keith298718

insert current date

I have a mysql table with several fields one of which is of a type date, in the past I am sure I could on inserting a record set the default value to the current date using NOW(). When I try this now I get an error saying incorrect value for my date field, even setting the default value in the data table itself gives me this message. What am I doing wrong , I am using MySQL version 5.1

Sign in to reply to this post

Jimmy Wu

Try inserting the current date and see if that works:
date-and-time-functions.html#function_curdate

The now function returns the date and the time, so that may be the issue.

Sign in to reply to this post

keith298718

no luck

Tried that and just about anything else I can think of. Using phpmyadmin I have tried just about every SQL function call I can think of and they all return "invalid default value for field type"
I have tried it on my local install and my webhost's install of mySQL and comes back the same invallid default value.

Thanks
Keith

Sign in to reply to this post

Jimmy Wu

Are you setting this as the default value or are you using the now function call in the query that you are using to insert the values?

According to this post in MySQL forums (although it is a bit old), you should not set the default value using the function call:
bug.php?id=2539

Sign in to reply to this post

keith298718

tried both

Jimmy
I have tried both ways setting it as default in the database table and also as a function call in datassist insert record , using now() or current_date() date() they all return an error stating that the value for my date field is incorrect this is what the message acctually says

Incorrect date value: 'NOW()' for column 'picadddate' at row 1

I have attached the page source and the SQL for the table in question

Thanks for your help
Keith

Attached Files
files.zip
Sign in to reply to this post

keith298718

insert current date

Jimmy
I have since tried a few things and if I change the data type to datetime for the field in the database and do an insert using phpmyadmin and curdate() as the value it works fine, but if I try and do the same from datassist insert I get the same error message as before.

Any ideas

Keith

Sign in to reply to this post

Jimmy Wu

It could be an issue of format that the date is in. After getting the curdate, try formatting it using the dateformat function:
date-and-time-functions.html#function_date-format

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...