0

Using datetime.strptime(11/12/18 02:20 PM, '%m/%d/%y %I:%M %p') I enter the date and time into sql server using a stored procedure and I get no errors, all seems fine. But the actual value in the database when checked is 2018-11-12 00:00:00.000. This is the value coming out of strptime 2018-11-12 14:20:00. Why am I not getting the time value? I have checked both the table design and Stored Procedure to make sure that datetime is being used throughout.

6
  • "No errors" does not necessarily mean "fine." Did you look at the actual value that is getting substituted before you just throw it over the wall at SQL Server? Commented Nov 12, 2018 at 17:41
  • Maybe this answer Inserting datetime into a MS SQL table using pyodbc might help! Though in this example they were getting errors. Commented Nov 12, 2018 at 17:43
  • I will check now for actual value Commented Nov 12, 2018 at 17:51
  • This is the value coming out of strptime 2018-11-12 18:20:00 Commented Nov 12, 2018 at 17:55
  • Is it possible the column in SQL Server is DATE instead of DATETIME? Seems unlikely if you're getting the 00:00:00.000 at the end, but worth checking. Commented Nov 12, 2018 at 18:16

1 Answer 1

0

Ok, Figured it out, since I was doing this in 'Ignition' and using a python library, I went into the library file. It was using 'system.db.createSPProcCall' and 'registerInParam' where you must include a value and a type. Since 'system.db.type' does not have a datetime, they had used DATE, wrong! I changed it to use TimeStamp. It worked fine after that. A shout out to @Jeffrey Van Laethem for setting me on the right path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.