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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:09:00+00:00 2026-06-18T18:09:00+00:00

I have a string in my DB2 database which is physically located in US.

  • 0

I have a string in my DB2 database which is physically located in US. I have a column value set to this string ‘2011-12-31 00:00:00’ which indicates year 2011, month december and day 1st of the december.

I’m retrieving this as a string in my client program which is running in UK and the UI is set to local culture(the default). My client program also runs in US as well as in Hongkong with the culture set to the local culture there i.e US and HK respectively.

I’m using the following code for parsing the string into a datetime. I’m not very sure whether this is going to work, and I could’t find any good link which points me to that direction. Could you please tell me whether this will work in various cultures, if not why?

string quarterStartDate = "2011-12-01 00:00:00";
DateTime quarterStart;
DateTime.TryParse(quarterStartDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out quarterStart);
return quarterStart;

I have a test which works as per my requirement, but again ‘am not too sure whether this will work when the UI is going to run in a different country.

  string quarterStarter = "2011-12-01 00:00:00";        
  DateTime quarterStart; 
  DateTime.TryParse(quarterStarter,CultureInfo.InvariantCulture,DateTimeStyles.None,out quarterStart);    
  Assert.IsTrue(quarterStart.Year == 2011);
  Assert.IsTrue(quarterStart.Month == 12);
  Assert.IsTrue(quarterStart.Day == 1);
  • 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-06-18T18:09:01+00:00Added an answer on June 18, 2026 at 6:09 pm

    I would strongly suggest that as you know the format in advance, you use TryParseExact instead of TryParse:

    bool success = DateTime.TryParseExact(quarterStarter, "yyyy-MM-dd HH:mm:ss",
                                          CultureInfo.InvariantCulture,
                                          DateTimeStyles.None,
                                          out quarterStart);
    

    Note that you should check the return value of TryParseExact to check that it’s parsed correctly – if you’re fine with an exception, just use ParseExact instead.

    It’s entirely possible that your existing code would work just fine – after all, you’re already providing the invariant culture – but specifying the format makes it clearer what you really expect, and also means you’ll detect if a value in an unexpected format is provided.

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

Sidebar

Related Questions

I have a table in db2 which has the following fields int xyz; string
I have string like this : <input name=my_name id=my_id value=my_value class=my_class /> I would
I have to search a DB2 database for a string that is a concatenation
I have a List(Of String) which corresponds to types on our database table. We
I have a .Net application which interacts with a DB2 database (Entity Framework, not
I have string that look like Array that fetched from other webservice like this
I have string as abvd.qweqw.sdfs.a=aqwrwewrwerrew . I need to parse this string and get
I have string like this: G:\Projects\TestApp\TestWeb\Files\Upload\file.jpg How can I remove all text before Files
My database has about 30 views, most of which have a reference to another
I have an existing DB2 database at my job. (At least, I think it's

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.