ASP
  Home arrow ASP arrow Page 3 - Enhancing Readability with ASP
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

Enhancing Readability with ASP
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 60
    2004-06-22

    Table of Contents:
  • Enhancing Readability with ASP
  • Trim the String
  • What Does 07/13/2004 Mean?
  • How to Use It

  • 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


    Enhancing Readability with ASP - What Does 07/13/2004 Mean?


    (Page 3 of 4 )

    When you print out a date in ASP, by default you'll get the format of MM/DD/YYYY. There are all numeric references, and they are just plain annoying. Let's face it, most of us hate having to translate in our heads which month '07' is. Even though we've known all our lives that there are only 12 months, and have had many years to remember their numeric order, we still catch ourselves thinking “January, February, March, April...” and so on, all the while ticking them off with our fingers.

    Now, that takes time, and if I'm quickly glancing at a screen of data, to obtain specific information, I don't feel like wasting time figuring out what the date means. So to cater to this, I've built a function to modify and re-deliver a date, in a format that we humans are most comfortable reading and referring to. It's called niceDate(), and here it is:

    '============================================

    function niceDate( dt, excludeDay )

    '============================================

    if not isDate( dt ) then

    niceDate = ""

    exit function

    end if

    dim d

    d = ""

    select case Weekday( dt )

    case 1:

    d = "Sun "

    case 2:

    d = "Mon "

    case 3:

    d = "Tues "

    case 4:

    d = "Wed "

    case 5:

    d = "Thur "

    case 6:

    d = "Fri "

    case 7:

    d = "Sat "

    end select


    if typeName( excludeDay ) = "Boolean" then

    if excludeDay then d = ""

    end if

    d = d & MonthName( Month( dt ), true ) & " " & Day( dt ) & ", " & Year( dt ) 'no carriage return here

    niceDate = d

    end function

    In essence, it's fairly simple. There's the initial type-checking, where we prevent errors that would result in trying to extract date information from a non-date string (the good ol' type mismatch error). Then we move into a select statement, where we figure out which day of the week it is, and provide the human-friendly version (after all, nobody knows they hate day #2, they just know that they hate Monday). You also have the option to exclude the day from the output, which is a nice way to shorten the resulting string.

    More ASP Articles
    More By Justin Cook


       · Thank you for this handy function!Just one thing to note: I had to change the...
     

    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-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT