Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 26, 2012 08:15 AM by bojangles
Feb 20, 2012 02:27 AM|LINK
I have a date field in my database that I would like to insert the current date on the server every time a new record is added to the table. I have a data type of “datetime” and the Default Value of Binding of “(getdate())” but it returns null, what should
I do in this case.
Feb 20, 2012 02:35 AM|LINK
set your default in the database, not the application.
Feb 20, 2012 02:42 AM|LINK
Thats what i'm trying to do but for some reason it's not doing it, i get null. Is there any reason you know of as to why I would get that?
Feb 24, 2012 06:37 AM|LINK
Thats what i'm trying to do but for some reason it's not doing it, i get null.
Would you please post the query when you insert getdate() record to your table? It will give us more information about your problem.
I found this thread which is talking about set date = getdate(). It may help you.
Please see :
Feb 26, 2012 08:15 AM|LINK
Thanks Chen Yu,
I’ve had a look through some Microsoft auto generated code, e.g.. the code generated for membership and the aspnet.mdf when you create a new MVC site and it looks like MS don’t rely on SQL Server adding the date time automatically. So I will do it this way
from now on.