ASP
  Home arrow ASP arrow Page 4 - What are Active Server Pages?
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

What are Active Server Pages?
By: Sriram K
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 226
    2004-05-24

    Table of Contents:
  • What are Active Server Pages?
  • Displaying the Current Date and Time
  • Example 1
  • Examples 2, 3 and 4
  • Cool Things You Can Do with Date, Time, and Text
  • Differences Between VBScript and JavaScript

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    What are Active Server Pages? - Examples 2, 3 and 4


    (Page 4 of 6 )

    Example 2

    Try typing this into a Web page:

    The time is <% =time %>. That means it's <% =minute(now) %>
    minutes past <% =hour(now) %> o'clock. When you view the page in Internet Explorer, you should see something like this:

    The time is 1:36:05 PM. That means it's 36 minutes past 13 o'clock.

    Remember, the hour function is based on a 24-hour clock. Later we'll see how to convert from the 24-hour clock to a 12-hour clock.

    Timevalue

    You probably won't ever use the timevalue function. It takes the different ways you can write the time, such as "2:24PM" and "14:24," and returns them in this format: "2:24:00 PM." This can be useful if you're using a function that needs to be given the time in that exact format.

    Example 3

    Earlier we saw how you can use the hour, minute, and second functions to break up the time into hours, minutes, and seconds. With the timevalue function, you can put them back together. Type this into a Web page:

    When it's 23 minutes and 5 seconds past 4 o'clock in the afternoon,
    that means it's <% =timevalue("16:23:05") %>.
    This is the same as <% =timevalue("4:23:05PM") %>
    or <% =timevalue("16:23:05PM") %>.

    Make sure you type "16:23:05PM" and not "16:23:05 PM." The "05" and the "PM." should be run together, not separated by a space. When you view the page in Internet Explorer, you should see:

    When it's 23 minutes and 5 seconds past 4 o'clock in the afternoon, that means it's 4:23:05 PM. This is the same as 4:23:05 PM or 4:23:05 PM.

    Displaying Text

    len

    The len function tells you how many characters are in a word or sequence of words. (The name "len" is an abbreviation of "length".) All characters are counted, including the space character. For example, to find the length of the sentence "The cat is on the mat," type this into a Web page:

    There are <% =len("The cat is on the mat.") %> characters in "The cat is on the mat."

    When you view the page in Internet Explorer, you should see this:

    There are 22 characters in "The cat is on the mat."

    left

    You can use the left function to look at the first few characters of a word or sequence of words. For example, to find the first character of "Frankenstein," type this into a Web page:

    "Frankenstein" begins with the letter <% =left("Frankenstein", 1) %>.

    When you view the page, you should see this:

    "Frankenstein" begins with the letter F.

    right

    To look at the last few characters of a word or sequence of words, use the right function. For example, to find the last three letters of "Wednesday," type this into a Web page:

    The last three letters of "Wednesday" are: <% =right("Wednesday", 3) %>.

    When you view this page, you should see this:

    The last three letters of "Wednesday" are: day.

    Example 4

    What if you wanted to take a few letters from the middle of something? How would you specify exactly where in the middle you wanted to be? For example, how would you take out just the "apple" part of the word "pineapples"?

    You could start with the fifth character from the left and then stop at the second character from the right. Or you could do it the following way.

    Try typing this into a Web page:

    <% =right("pineapples", 6) %> <% =left(right("pineapples", 6), 5) %>

    This line takes the last six letters of the word "pineapples," which make up the word "apples." Then it takes the first five letters of the word "apples," which make up the word "apple." When you view this page in Internet Explorer, you should see this:

    apples apple

    Then try typing this into a Web page:

    <% =left("pineapples", 9) %> <% =right(left("pineapples", 9), 5) %>

    This line takes the first nine letters of the word "pineapples," which make up the word "pineapple." Then it takes the last five letters of the word "pineapple," which make up the word "apple."

    When you view this page, you should see this:

    pineapple apple

    More ASP Articles
    More By Sriram K


     

    ASP ARTICLES

    - Using MySQL with ASP
    - ADO for the Beginner
    - ADO.NET 101: Data Rendering with a DataGrid ...
    - Introducing SoftArtisans OfficeWriter 3.0 En...
    - Getting Remote Files With ASP
    - The Real Basics of Functions in ASP
    - Enhancing Readability with ASP
    - Mimicking PHP's String Formatting Functions
    - Windows Server Hacks 12, 77, and 98
    - How to Sort a Multi-Dimensional Array
    - Developing an Information Management Tool wi...
    - What are Active Server Pages?
    - Getting Remote Pages with ASP
    - FTP’ing Files with ASP
    - Apply Single-Sign-On to Your Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT