Last post Dec 07, 2018 07:24 AM by Fei Han - MSFT
Dec 06, 2018 02:23 AM|shsu|LINK
I am having issue while inserting Date and Time in to oracle database. When I used date ,it is working but when I added time it is not working.Appreciate the Help
dissue.Text = System.DateTime.Now.ToString("dd/MMM/yyyy")
I paced the dissue.Text in the insert statement and working fine.but
dissue.Text = System.DateTime.Now.ToString("MM/DD/YYYY HH:MM:SS")
-> Not working
Dec 06, 2018 02:46 AM|DA924|LINK
Dec 06, 2018 04:35 AM|Rameezwaheed|LINK
Try the below code
dissue.Text = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt")
Refer the below article for more details
Hope it helps
Dec 06, 2018 12:37 PM|PatriceSc|LINK
You also changed the date format in addition to adding the time ??? Decide first which country convention you want to use. You could use
https://docs.microsoft.com/en-us/previous-versions/bz9tc508(v=vs.140) to select the needed culture rather than hardcoding date formats in your code.
When sending back dissue.Text to Oracle, this value should be converted back to a DateTime and used to feed a SQL parameter. This way your app should work without having to take care about handling a particular format (and potentially could work as well
if you want later to suppot some other language using a different convention for date values).
Dec 07, 2018 07:24 AM|Fei Han - MSFT|LINK
having issue while inserting Date and Time in to oracle database. When I used date ,it is working but when I added time it is not working.
To troubleshoot the issue, you can debug your code and check the actual SQL query of inserting data, and then you can execute that SQL query in your database which would show you detailed exceptions. Perhaps a invalid value are passed and inserted, which
cause the issue.
Besides, you an check
this article to know about "Insert a date/time value into an Oracle table".