Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Solve This Problem.
Please Avoid "Try to SQL Server Date Time Change using XYZ .... Command"
I Want to Solve this in .Net Instead in SQL Server
Posted
Updated 25-May-12 21:37pm
v3
Comments
OriginalGriff 26-May-12 3:04am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

Hi,

if Your date Format is dd/MM/yyyy then u need to convert it in sql Format
using following Code

C#
IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
          string   strDate = DateTime.Parse(txtDate.Text.Trim(), provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault).Date.ToString();


then u can pass it Db ok

Best Luck
 
Share this answer
 
Comments
OriginalGriff 26-May-12 3:19am    
Bad idea. Never pass data as strings unless you really, really have to. Instead pass it to SQL as a DateTime object - then SQL has no internationalization problems and can use it directly. It also means that the date can be more easily formatted to the output client preferred format, and that SQL can perform comparisons and maths on it.
Nilesh Patil Kolhapur 26-May-12 3:21am    
ok thanks sir

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