Active Server Pages - ASP.NET and ASP convert string to date
Before getting started...
if you want to surf the web and be TRULY ANONYMOUS (without cookies, tracking, spyware, popups, identity theft, and other unwanted stuff), take a look at using a cgi proxy. I HIGHLY recommend it!
Active Server Pages - ASP.NET and ASP convert string to date.
'Make sure your date is correct
'try "04/35/05"
'this causes an error because April only has 30 days
'It is corrected to "04/30/2005"
dim dateString as string = "11/30/2003"
dim convertedDate as Date = CDate(dateString)
The VB.NET Way.
DateTime dtDate = Convert.ToDateTime(strDate);
"Convert" is a class in a "System" namespace.
The C# way.
//string strDate="2002-10-03";
//string strDate="10/04/2002";
string strDate = "10/05";
DateTime dt = (DateTime)(TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));
Response.Write("<hr>" + dt.DayOfWeek);
Another example.
The following small ASP.NET Web page demonstrates using the String.Format method to apply some formatting to various variables.
<script language="C#" runat="server"> void Page_Load(Object sender, EventArgs e) { double price = 4.56; DateTime rightNow = DateTime.Now; int bigNumber = Int32.MaxValue;
lblPrice.Text = String.Format("{0:c}", price); lblTime.Text = String.Format("{0:T}", rightNow); lblDate.Text = String.Format("{0:d}", rightNow); lblBigInt.Text = String.Format("{0:#,###}", bigNumber); } </script>
<html> <body>
The price is: <asp:label runat="server" id="lblPrice" /> <p> The time is: <asp:label runat="server" id="lblTime" /> <p> The date is: <asp:label runat="server" id="lblDate" /> <p> The biggest 32-bit integer is <asp:label id="lblBigInt" runat="server" /> </body> </html>
|
The output for the above web page is:
The price is: $4.56
The time is: 12:14:52 PM
The date is: 1/19/2002
The biggest 32-bit integer is 2,147,483,647
|
What is ASP?
ASP is Active Server Pages. It is Microsoft's server-side technology, for dynamically-generated web pages. It is marketed as an add-on to Internet Information Services (IIS). asp convert string to date
ASP programming is made easier with various built-in objects. Each object corresponds to a group of frequently-used functionality, useful for creating dynamic web pages. In ASP 3.0 there are six such built-in objects: Application, ASPError, Request, Response, Server and Session.
ASP Objects.
Session, for example, is a cookie-based session object. It maintains variables from page to page, throughout the user session of a website visitor. The Application objects maintains variables used by the web server, regardless of the web page or visitor. The Response object writes output. The Request object retrieves information from an HTTP request. The ASPError object handles errors. asp convert string to date
Language options.
Most ASP pages are written in VBScript. Other scripting languages are available using the @Language directive. JScript (Microsoft's implementation of JavaScript) is another available language. PerlScript (Perl) and others are available as third-party add-ons. asp convert string to date
|
|