BrainDump
  Home arrow BrainDump arrow Page 4 - VBScript: More Fun with the Date Functions
Iron Speed
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 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
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? 
BRAINDUMP

VBScript: More Fun with the Date Functions
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-25

    Table of Contents:
  • VBScript: More Fun with the Date Functions
  • Parsing out the Month, Day, and Year from the Current Date:
  • Serial Dating
  • What Day is it Anyway?
  • Day, Month, Year, Hour, Minute, Second
  • Figuring Out Which Month it is

  • 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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    VBScript: More Fun with the Date Functions - What Day is it Anyway?
    (Page 4 of 6 )

    If we want to know which day of the month it is (represented by a value ranging from 1-31), we can use the Day() function, like so:


    <html>

    <body>

    <script type="text/vbscript">

    document.write("Today's date is: ") & Date & ("<br />")

    document.write("The day of the month is ") & Day(Date)

    </script>

    </body>

    </html>

    This results in the printout:

      Today's date is: 12/28/2008
      The day of the month is 28

    Formatting the Date/Time with the...(drum roll please) FormatDateTime() Function

    If you want to specify how your date/time looks, one way to do so is with the FormatDateTime() function. There are five different formats you can use, starting with 0 and working through to number 4. Here they are in code:


    <html>

    <body>

    <script type="text/vbscript">

    document.write("Today's date is: ")

    document.write(FormatDateTime(Date(),4))

    document.write("<br />")

    document.write("Today's date is: ")

    document.write(FormatDateTime(Date(),3))

    document.write("<br />")

    document.write("Today's date is: ")

    document.write(FormatDateTime(Date(),2))

    document.write("<br />")

    document.write("Today's date is: ")

    document.write(FormatDateTime(Date(),1))

    document.write("<br />")

    document.write("Today's date is: ")

    document.write(FormatDateTime(Date()))

    document.write("<br />")

    </script>

    </body>

    </html>

    And the result:

      Today's date is: 00:00
      Today's date is: 12:00:00 AM
      Today's date is: 1/28/2008
      Today's date is: Monday, January 28, 2008
      Today's date is: 1/28/2008

    More BrainDump Articles
    More By James Payne


       · Welcome back to our continuing discussion on VBScript date functions. Here we learn...
     

    BRAINDUMP ARTICLES

    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway