BrainDump
  Home arrow BrainDump arrow VBScript: More Fun with the Date Functions
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? 
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
     
     
    ADVERTISEMENT


    VBScript: More Fun with the Date Functions


    (Page 1 of 6 )

    In our first article on VBScript date functions, way back in January, we covered CDate, Date, DateAdd, and DateDiff. In this article, we'll be picking up where we left off. We still have a lot of ground to cover; who knew dates were so important? So let's get started.

    If you happened to miss the wise words of my first VBScript article on dates, never fear, you can review it right here. If you'd rather not, that's okay too.

    We left off discussing the difference between my birth and Jesus's hypothetical hundredth birthday using the DateDiff function. Here we will carry on beginning with a little number I like to call the DatePart...

    But first, our lovely table:

     

    Function Name

    What It Does

    CDate

    Used to change the date and time expression to the variant subtype Date

    Date

    Used to return the current date, based on your system date

    DateAdd

    Used to return a date in which a time interval you specified has been added

    DateDiff

    Used to return the difference between two dates

    DatePart

    Used to return a specific part of a date

    DateSerial

    Used to return the date for a year you specify: year, month, and day

    DateValue

    Used to return a date

    Day

    Used to return a day of the month; Returns a number between 1 and 31

    FormatDateTime

    Used to return an expression. Formats it as a date or as a time

    Hour

    Used to return the hour. Returns a number between 0 and 23.

    IsDate

    Used to check if a value can be converted to a date. Returns a boolean value.

    Minute

    Used to return the minutes of an hour. Value range is between 0 and 59.

    Month

    Returns the month. Value returned is a number ranging from 1-12.

    MonthName

    Returns the name of a month you specifiy.

    Now

    Returns the date and time based on your system's date and time.

    Second

    Returns the seconds of the minute. A value between 0 and 59.

    Time

    Used to return the system time.

    Timer

    Used to return the amount of seconds since 12:00 am.

    TimeSerial

    Used to return the time for a specified hour, minute, and second.

    TimeValue

    Used to return a time

    Weekday

    Used to return a day of the week. Value is a number between 1 and 7

    WeekDayName

    Used to return the name of a day in the week

    Year

    Used to return a year. Value is a number representing the year. (Duh)

    Partying with the DatePart Function

    DatePart allows you to extract a part of a date. Note that like most date functions, you can use the following parameters:

    • yyyy: Used for year

    • q: Used for quarter

    • m: Used for month

    • y: Used for day of the year

    • d: Used for Day

    • w: Used for Weekday

    • ww: Used for week of year

    • h: Used for hour

    • n: used for minute

    • s: Used for second

    Here are some samples:

    More BrainDump Articles
    More By James Payne


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

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek