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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:34:26+00:00 2026-06-10T09:34:26+00:00

I am fetching date from textbox and passing it to dateTime by passing it

  • 0

I am fetching date from textbox and passing it to dateTime by passing it though a function,

BUT it gives me two different results

DateTime Fromdate1 = devTools.ParseDate(datepicker1.Text);

TextBox —>OutPut

02/09/2012 –> 2/9/2012 12:00:00 AM

30/08/2012 –> 8/30/2012 12:00:00 AM

public DateTime ParseDate(string s)
    {
        DateTime result;
        if (!DateTime.TryParse(s, out result))
        {
            string[] formats = { "dd'/'MM'/'yyyy" };
            result = DateTime.ParseExact(s, formats, new CultureInfo("en-US"), DateTimeStyles.None);
            //result = DateTime.ParseExact(s, "dd'/'MM'/'yyyy", System.Globalization.CultureInfo.InvariantCulture);
            //result = result.AddDays(1);
        }
        return result;
    }

What is the problem here,Is there a prper way to get constant output type,also it will create problems in DB since 08/09 will be checked against 09/08 and vice versa !

One more problem in SQL :

Select convert(nchar(10),FromDate, 103) AS FromDate,convert(nchar(10),ToDate, 103) AS ToDate FROM Tbl_PropertyRoomSeasonPrices

OUTPUT :

28/08/2012 | 09/01/2012

dd/mm/yyyy | mm/dd/yyyy
(CORRECT) (WRONG)

but 103 for fromDate and 101 for toDate makes it both same,Why the variations ??

  • 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-10T09:34:28+00:00Added an answer on June 10, 2026 at 9:34 am

    It seems to me that the “problem” here is just how you’re interpreting the output. Your method returns a DateTime – not a string – so when you’ve written. “02/09/2012 –> 2/9/2012 12:00:00 AM” you presumably mean that an input of string “02/09/2012” gives you a result DateTime which happens to have a string representation of “2/9/2012 12:00:00 AM” in whatever way you’re converting it to a string, e.g. by looking in the debugger. That will use the current culture and the default format – but that’s not part of the DateTime value itself.

    Look at the properties of the DateTime and you’ll see it’s been parsed correctly.

    also it will create problems in DB since 08/09 will be checked against 09/08 and vice versa

    No it won’t. Not if you’re doing things properly – using parameterized SQL and specifying the DateTime value for the property. It could well give you problems if you’re including the value directly in your SQL, but that’s a bad idea anyway.

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

Sidebar

Related Questions

I am trying to retrieve results from this query, but it is not fetching
I am fetching two separate variables with time & date as separate values: $v['EventDate']
I am fetching some values in a forEach clause data.forEach(function(content){ ... controller.setAttribute(value from data);
I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text
I want to compare between two dates. From both the dates, I am fetching
while fetching data from MySQL for today's date, what should be preferred why 1)
i was fetching this date from table in the database like this format Sunday
I am fetching data from MongoDB as follows: @bs = coll2.find(date => {$gte =>
My application is fetching data from a Xml file on a webpage. That date
I have two classes that perform date date range data fetching for particular days.

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.