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 5975579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:06:19+00:00 2026-05-22T21:06:19+00:00

In Microsoft SQL Server Management Studio, after calling the stored procedure, I can see

  • 0

In Microsoft SQL Server Management Studio, after calling the stored procedure, I can see that the time has the format 2011-05-20 19:56:09 in table.

However, in my C# program, after using an OdbcConnection to get the record from the table, I find that the time is in the format 05/20/2011 19:56:09. So I manually convert the format MM/DD/YYYY hh:mm:ss to YYYY-MM-DD hh:mm:ss (Actually, how do I verify the format is h or HH since the hour shown is 19?).

My question is why and in which part of connection, the format is changed? How can I set invarient culture in my connection?

cmd = new OdbcCommand("{?=CALL stored_procedure_in_SQL(?,?)}", m_SqlConn);
cmd.Parameters.Add(new OdbcParameter("RETURN_VALUE", OdbcType.Int, 4,
    ParameterDirection.ReturnValue, false, 0, 0, null, 
    DataRowVersion.Default, null));

//@parameter1
cmd.Parameters.Add("@parameter1", OdbcType.VarChar, 50).Value = value1;

//@parameter2
cmd.Parameters.Add("@parameter2", OdbcType.Int)=value2;

object objTime=ds.Tables[0].Rows[0][0]
Console.WriteLine(objTime.Tostring()) //05/20/2011 19:56:09
DateTime dateTime = Cdate(objTime, "MM/dd/yyyy h:mm:ss tt"); 
//2011-05-20 19:56:09 
Console.WriteLine(dateTime.ToString("yyyy-MM-dd HH:mm:ss")); 

//Function Cdate
static public DateTime Cdate(object val, string format)
{
    // check if the object is a date time alread
    string str;
    if(val is DateTime)
    {
        // Since val is already a dateTime,Return here
        return (DateTime)val; 
    }

    // convert via string
    if(val != DBNull.Value)
    {
        str = val.ToString().Trim();
    }
    else
    {
        str = "";
    }

    if(str == "")
    {
        return DateTime.MinValue;
    }
    else
    {
        return DateTime.ParseExact(str, format, 
            CultureInfo.InvariantCulture);
    }
}
  • 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-22T21:06:20+00:00Added an answer on May 22, 2026 at 9:06 pm

    You can’t set a DateTime format on a connection string.

    What you are seeing are simply different formattings of a certain (internal) representation of DateTime.

    The formatting is determined by the tools you use and for .NET code the culture your logged in with.

    When you want to display the time, then you need to format, though when using a custom format string like you have, there are no CultureInfo elements involved.

    Check the different ToString overloads on DateTime.

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

Sidebar

Related Questions

I use Microsoft SQL Server Management Studio a lot. Every time I'm starting the
I have a View in microsoft sql server management studio that uses the code
I have a database (using Microsoft SQL Server Management Studio Express) that is currently
In Microsoft SQL Server Management Studio 2008 there is a Generate scripts... option under
I'm using Microsoft SQL Server Management Studio to work with a database. I'm only
I'm using Microsoft SQL Server 2008 Management Studio to create a relational schema by
I was wondering if there are any alternatives to Microsoft's SQL Server Management Studio?
In Microsoft SQL Server Management Studio 2008, is there a secret to be able
System Specifications Microsoft SQL Server Management Studio 9.00.4035.00 Microsoft Analysis Services Client Tools 2005.090.4035.00
in Microsoft SQL Server Management Studio, I use File -> Open -> File (Ctrl

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.