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

  • Home
  • SEARCH
  • 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 6838093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:33:19+00:00 2026-05-26T23:33:19+00:00

I am using below code DateTime dtt=new DateTime(); dtt = Convert.ToDateTime(FromDate); // DateTime dtt

  • 0

I am using below code

    DateTime dtt=new DateTime();
    dtt = Convert.ToDateTime(FromDate);


  //  DateTime dtt = DateTime.Parse(FromDate); //this also gives the same error

    con = new MySqlConnection(conString);
    con.Open();
    for (int i = 1; i <= TotalDays; i++)
    {         
        string updateHotelBooking = "Update tbl_hotelbookingdetail set `BookedRoom`=`BookedRoom`+"+1+", `AvailableRoom`=`TotalRoom`-`BookedRoom` where `HotelID`="+HotelID+" AND `CurrentDate`='"+dtt.ToString("dd-MM-yyyy")+"'";
        MySqlCommand cmd7=new MySqlCommand(updateHotelBooking,con);
        cmd7.ExecuteNonQuery();                
        dtt = dtt.AddDays(1);
    }

This code is in one of my webservice which I am using for iPhone application.

here FromDate is string with value in this formate 15-11-2011 which is coming from the application in string format. I am converting it to DateTime because in loop of total days
I need to add day to dtt.

It is working fine on local host with dtt value 15-11-2011 00:00:00

but when I published it,it gives error

String was not recognize as valid DateTime

  • 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-26T23:33:19+00:00Added an answer on May 26, 2026 at 11:33 pm

    This is almost certainly because your server uses a different culture by default – and your code is just using the current thread culture.

    You can specify this using DateTime.Parse – or specify the pattern explicitly with DateTime.ParseExact or DateTime.TryParseExact – but we need to know more about where the string is coming from to suggest the best approach. Is it from the user? If so, you should use the user’s culture to parse it. Is it a specific format (e.g. from an XML document) instead? If so, parse using that specific format.

    Ideally, get rid of the string part entirely – if you’re fetching it from a database for example, can you store it and fetch it as a DateTime instead of as a string? It’s worth trying to reduce the number of string conversions involved as far as possible.

    EDIT: To parse from a fixed format of dd-MM-yyyy I would use:

    DateTime value;
    if (DateTime.TryParseExact(text, "dd-MM-yyyy",
                               CultureInfo.InvariantCulture,
                               DateTimeStyles.AssumeUniversal,
                               out value))
    {
         // Value will now be midnight UTC on the given date
    }
    else
    {
        // Parsing failed - invalid data
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using below code to change the the font type of text view.
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
I am using below code to create a reminder in Google calendar (using Google
In past, I am using Listview and using below code can show a particular
I want to enable auto update script in flex3. i am using below code
I am actually having a list of text boxes. I am using below code
using the below code for decoding json $categories = json_decode($data); $categories = $categories->data; where
I am using the below code to capture the ctrl + alt + Q
I am using the below code to close the window, by searching the window
I am using the below code to block the taskbar which is working perfectly.

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.