Click here to Skip to main content
15,611,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to store the date in database...but the date which i'm inserting is not storing..since i'm beginner i cant able to found out wats the problem...can yu help??
Gopinath1005 6-Jan-12 6:03am    
also suggest me in what format i want to insert???
[no name] 6-Jan-12 7:31am    
My preference is SQL Server 'Unseperated' format for datetime literals

'yyyymmdd hh:mm:ss.mmm'

because its not dependent upon any weird enviroment settings, but you can also use ISO 8601, here is a link I always find useful...
Richard MacCutchan 7-Jan-12 13:46pm    
Silly idea; use the DateTime type.

Always store dates as DateTime values. You only ever need to format it when you need to display it on an output device.
Share this answer
Share this answer
yyyy-mm-dd hh:mm:ss:mmm.....

finally made it...
Share this answer
Before storing date convert your date using following code

IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
string strDate = DateTime.Parse(txtDate.Text.Trim(), provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault).Date.ToString();
it works
Best Luck
Share this answer

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