Answered by:
Short date being ignored from UPDATE query in 2016 table

Question
-
I have a table that excepts some dates. I have the field formatted for short date. In VBA I have an UPDATE statement that sends a short date to the DB. When I open the table I see that the field not only has a time element it also has the default date of 12/30/1899 totally ignoring the value in the statement. Below is an example of the sql query being executed on the DB.
UPDATE Projects Set Start = 10/23/2015, End = 1/1/2016, DepartmentCreated = True, Completed = True WHERE projectID = 5
I cannot figure out what is happening and it is driving me nuts. As you can see that is clearly a short date and the DB simply ignores it. I get no errors and anything to indicate an issue.
Ty
Tuesday, May 10, 2016 5:12 PM
Answers
-
Hi Ty. Values other than numbers need delimiters. For dates, it's the hash tag. For example:
UPDATE Projects SET Start=#10/23/2015#, End=#1/1/2016#, DepartmentCreated=True, Completed=True WHERE ProjectID=5
Hope that helps...
- Proposed as answer by Edward8520Microsoft contingent staff Wednesday, May 11, 2016 3:01 AM
- Marked as answer by TyBarton Wednesday, May 11, 2016 10:22 AM
Tuesday, May 10, 2016 5:34 PM
All replies
-
Hi Ty. Values other than numbers need delimiters. For dates, it's the hash tag. For example:
UPDATE Projects SET Start=#10/23/2015#, End=#1/1/2016#, DepartmentCreated=True, Completed=True WHERE ProjectID=5
Hope that helps...
- Proposed as answer by Edward8520Microsoft contingent staff Wednesday, May 11, 2016 3:01 AM
- Marked as answer by TyBarton Wednesday, May 11, 2016 10:22 AM
Tuesday, May 10, 2016 5:34 PM -
That worked. Thanks DB.
I don't remember ever having to do that in VB sql but no matter. It works.
Wednesday, May 11, 2016 10:23 AM -
Hi. You're welcome. Glad to hear you got it to work. Good luck with your project.Thursday, May 12, 2016 3:34 PM
-
When I open the table I see that the field not only has a time element it also has the default date of 12/30/1899..............
? Format(10/23/2015, "dd mmmm yyyy hh:nn:ss")
30 December 1899 00:00:19
Ken Sheridan, Stafford, England
Thursday, May 12, 2016 5:37 PM