Click here to Skip to main content
15,905,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii..

In C#,DateTime Picker uses date in dd/mm/yyyy format(Simple Needed Format So).
And Mysql uses yyyy/mm/dd format.

But,when u store or retrieve Date from database the format is not supported.
How to solve such problem.

Thanks
Posted
Updated 10-Feb-12 17:32pm
v2

Hi,

select convert(varchar,getdate(),103) as [Date] from tablename
hope it will help
best luck
 
Share this answer
 
Comments
member60 10-Feb-12 23:41pm    
gffghfhfh
HI FRIEND,

These may help you,just change only the last argument and see the output in sql

SQL
SELECT CONVERT(VARCHAR(10),GETDATE(),110)
SELECT CONVERT(VARCHAR(10),GETDATE(),100)
SELECT CONVERT(VARCHAR(10),GETDATE(),102)



Please once you check the below link,
http://www.w3schools.com/sql/func_convert.asp[^]
 
Share this answer
 
v2
try this,
.ToString("yyyy/mm/dd")while storing to DB.

refer:
http://www.csharp-examples.net/string-format-datetime/[^]
 
Share this answer
 
Refer this link

http://www.sql-server-helper.com/tips/date-formats.aspx[^]

I hope this might help you. If you have any doubt revert back to me
 
Share this answer
 
Use This During Saving Into DB and retrieving from DB.

C#
SELECT CONVERT(DATETIME, '" + string.Format("{0:dd-MM-yyyy}", YourDate) AS MyDate FROM TableName

Hope This help you
 
Share this answer
 
v3

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