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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:19:54+00:00 2026-06-05T13:19:54+00:00

I am getting an error ‘String was not recognized as a valid DateTime.’ by

  • 0

I am getting an error ‘String was not recognized as a valid DateTime.’ by using the following code.

NewRow["ExpiryDate"] = DateTime.ParseExact(SelectedRow.Cells[9].Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); 

where selectedRow is row of database. The code is written in RowCommand event.
Value in SelectedRow.Cells[9].Text is in dd-MM-yyyy format on client side where as it is different on server side.

How can I write generic code that will work for all datetime format?

  • 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-05T13:19:57+00:00Added an answer on June 5, 2026 at 1:19 pm

    You have to specify the date format for dd-MM-yyyy data.

    Use following method:

    DateTime.ParseExact Method (String, String[], IFormatProvider, DateTimeStyles)
    

    Sample:

     string[] formats = { "dd-MMM-yyyy", "dd/MMM/yyyy", "dd-MM-yy","d/M/yy"};
     string dateString = "1/1/10";
    
     DateTime date=DateTime.ParseExact(dateString ,formats,
        System.Globalization.CultureInfo.InvariantCulture,
         System.Globalization.DateTimeStyles.None);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting error using the following code snippet jQuery(document).ready(function() { jQuery.ajax({ url: url, type:
I'm getting error C3095: 'Xunit::Extensions::InlineDataAttribute': attribute cannot be repeated in C++/CLI code but not
i'm getting error cannot find symbol in netbeans while using the below code for
Getting error with the following code: import java.util.Scanner; public class FahrenheitToCelsius{ public static void
i am getting error using this syntax this.Page.ClientScript.RegisterStartupScript(typeof(string), Test, alert('<%=Resources.Text.Header_Login%>');); please any suggestion reply
I am getting error Application is not responding; process terminated when I am using
I am getting error the modifier public is not valid for this item this
I'm getting error while using replace in an update statement in sql server 2008.
getting error: ActiveRecord::StatementInvalid (PGError: ERROR: argument of HAVING must be type boolean, not type
I ma getting error like Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.Unit' in the

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.