Abdurahman Almatrodi
asked on
DateTime in MS SQL 2000 With C#
I've an application developed in C# connecting to MS SQL 2000. And, some user have dd/mm/yyyy hh:mm AM format, others have mm/dd/yyyy. I got error when I try to insert an new record or work with date.
What is the shortest way to solve this issue?
ASKER
I am using such as:
String.Format("INSERT INTO MyTable (RecDate) VALUES ({0}) WHERE RecID = {1}", '19/08/2009', 21)
The error is coming from SQL 2000 itself.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. It works well.
May you guide me to a link that explain this matter.
I would start with this link, for the cast/convert function:
http://msdn.microsoft.com/en-us/library/ms187928.aspx
http://msdn.microsoft.com/en-us/library/ms187928.aspx
ASKER
Dear Angel
What I need to know is how String.Format change the date.
Thanks
What I need to know is how String.Format change the date.
Thanks
in c# part, ensure you can parse the user input into a c# date, from there it's dead easy:
Open in new window