Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:21:30+00:00 2026-05-26T16:21:30+00:00

It seems that the .net DateTime object defaults to whatever format the computer is

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:21:31+00:00Added an answer on May 26, 2026 at 4:21 pm

    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

    string mystatment = "Insert into TableName (column1, datecolumn) values (?,?)"
    
    OleDbCommand cmd = conn.CreateCommand();
    cmd.Commandtext = mystatement;
    cmd.Parameters.AddWithValue("@column1", mycolumn1variable);
    cmd.Parameters.AddWithValue("@datecolumn", yourDateTimeVariable);
    

    if you are properly doing this with production code make sure you have exception handling etc.

    using (OleDbConnection conn = new OleDbConnection("connection string"))
    {
        using (OleDbCommand cmd = conn.CreateCommand())
        {
            cmd.CommandText = "Insert into TableName (column1, datecolumn) values (?,?)";
    
            OleDbParameter param;
            param = new OleDbParameter("name",  OleDbType.VarChar, 36); // if you know the size of the column specify it
            param.Value = mycolumn1variable;
            cmd.Parameters.Add(param);
    
            param = new OleDbParameter("mydate", OleDbType.Date); // if you know the size of the column specify it
            param.Value = yourDateTimeVariable;
            cmd.Parameters.Add(param);
    
            conn.Open();
            cmd.ExecuteNonQuery(); //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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning ASP.NET MVC Framework, From some articles like this , it seems that
it seems that Markdown.NET does not escape the following: <script> which is kind of
I have a .NET DLL that writes to the Trace. But it seems that
It seems that anyone can snoop on incoming/outgoing .NET web service SOAP messages just
it seems that I just solved my problem why I couldn't use the ASP.NET
I'm getting back into .NET development after a couple years and it seems that
How ASP.NET compiles its assemblies generally confuses me. It seems that I cannot program
I have trouble to expose a .NET assembly in COM. It seems that I
I have a .NET 2.0 server that seems to be running into scaling problems,
I see that JSON.NET has a DateTime converter: string javascriptJson = JsonConvert.DeserializeObject(entry, new JavaScriptDateTimeConverter());

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.