andrewmilner
asked on
c# Converting DateTime from en-gb to en-us
I have an en-gb web app that is posting data to a WebService that then needs to convert the posted en-gb datetime to en-us before putting it in the database.
How would I do that with C# code?
How would I do that with C# code?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The DateTime is being passed as a string but I'm building up a command to insert the SQL
like set TheDateTime = " + DateTime "
And because my local is set to en-gb it's therefore dumping the datetime into the sql insert statement as en-gb which the sql server rejects.
If I used parameters on the Insert statement would this go away?
like set TheDateTime = " + DateTime "
And because my local is set to en-gb it's therefore dumping the datetime into the sql insert statement as en-gb which the sql server rejects.
If I used parameters on the Insert statement would this go away?
ASKER
sorry, no its not a string its a DateTime thats how its being passed but in en-gb format as set in web config.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cool thanks. I'll try the parameters.
If you're using strings, you could use DateTime.ParseExact
Open in new window