Note that there are some explanatory texts on larger screens.

plurals
  1. POThe Conversion Between Dates and Strings in ASP.NET C#
    primarykey
    data
    text
    <p>I worked now in a dynamic ASP.NET C# web application that connects to a Sybase database using ODBC and my main problem is the conversion between datetime and string data types in my application.</p> <p>The database saves the datetime data in the following form:-</p> <pre><code>7/11/2011 05:05:05 I think it is in the pattern of "MM/dd/yyyy hh:mm:ss" </code></pre> <p>I need to call a web service and pass some datetime parameters to get the correct output. The static datetime format that is accepted by the web service is:-</p> <pre><code>11/07/11 09:09:09 I think it is in the pattern of "dd/MM/yy hh:mm:ss" </code></pre> <p>I tried using the following functions separately</p> <pre><code>string s = d.toString(string format) DateTime d = Convert.ToDateTime(string s) DateTime d = s.Datetime.Parse(string format) DateTime d = s.Datetime.ParseExact(string format) </code></pre> <p>to convert the dates I got from the database to be suitable to be passed to the web service but it always gives me different exceptions like:-</p> <p>Exception:System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s) at WebApplication1.WebForm1.callWebservice() </p> <p>I do not know how I should use and convert dates in the proper way and I get disappointed as I try many examples and functions but I can not get the right methodlogy.</p> <p>I hope that I find someone who could help and Thanks in advance.....</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload