Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello , I Want to stored Time In Database as HH/MM/- AM/PM formate But when i Insert this values using ado.net i got an error like String was not recognized as a valid DateTime. anyone can help me regarding this issue....
Posted
Comments
F-ES Sitecore 1-Feb-16 7:29am    
Dates and times only have a format when they are converted to a string to display. You can't store a date\time in the database as a certain format, you simply store it as a date\time and when you come to display it show it in the format of your choice.
Member 12211068 1-Feb-16 7:44am    
can you show me any example
F-ES Sitecore 1-Feb-16 8:26am    
That depends on how you're interacting with the database. If you're using ADO.net then use the SqlCommand object and use the Parameters collection

comm.Parameters.AddWithValue("@DateParam", yourDateVariable);

1 solution

You never format date or time as string for storing it in the database...You store it as binary value and format it only when it comes to the UI!!!
 
Share this answer
 
Comments
Member 12211068 1-Feb-16 7:44am    
can you show me any example

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900