It seems that the .net DateTime object defaults to whatever format the computer is set to. As I’m from the UK, this means that the DateTime object is DD/MM/YYYY.
This, typically, is fine, but I’m trying to use the DateTime object to put the current time in on a record submission on an Access database. Access (or SQL in general, don’t really know) requires that the date is formatted in a MM/DD/YYYY format.
Is there a way I can have the DateTime object just format the date in the MM/DD/YYYY format, or am I going to have to convert to string, switch the string around, and insert that?
If you are inserting into a database don’t use a Date String. Use a Parameter Object and give the Value the date object.
for access
if you are properly doing this with production code make sure you have exception handling etc.
for sql you use the named @parameters instead of the ? in your statement and use a SqlCommand instead.
If it’s for screen display, repect the users settings and format based on their culture.