Customer Login  .   Webmail Login  .   About Us  .   Contact Us
Go to: Articles List

Date Manipulation Part 4 : Getting the day, month, year, weekday, and weekday name

There are five functions that you can call, pass a valid date, and they will return to you the requested part of the date. Below I will detail each of them and show an example of their use:

Day(ValidDate)
- returns the day of the ValidDate, a number between 1 and 31

Month(ValidDate)
- returns the month of the ValidDate, a number between 1 and 12

Year(ValidDate)
- returns the year of the ValidDate, a number like 1997

Weekday(ValidDate[, FirstDayOfWeek])
- returns the weekday of the ValidDate, a number 1 - 7
- what the function returns depends on what day is the first day of the week, you can set this, or use the default - Sunday
- to set the FirstDayOfWeek parameter use 1-7, where 1 is Sunday

WeekDayName(DayOfWeek, Abbreviate, FirstDayOfWeek)
- returns the name of the day of the week that you specify.
- DayOfWeek is a number representing the day of the week you want the name for (1-7)
- Abbreviate is a boolean value to tell the function whether or not you want the name that comes back to be abbreviated or not (true or false)
- to set the FirstDayOfWeek parameter use 1-7, where 1 is Sunday

An example of the above functions in use is:

var1 = "04/04/1999"<br>
Response.Write("var1 = " & var1 & "<br>")
Response.Write("For var1 the day is " & Day(var1) & "<br>")
Response.Write("For var1 the month is " & Month(var1) & "<br>")
Response.Write("For var1 the year is " & Year(var1) & "<br>")
Response.Write("For var1 the weekday is " & WeekDay(var1, 1) & "<br>")
Response.Write("For var1 the weekdayname is " & WeekDayName(WeekDay(var1), false, 1) & "<br>")

Results:
var1 = 04/04/1999
For var1 the day is 4
For var1 the month is 4
For var1 the year is 1999
For var1 the weekday is 1
For var1 the weekdayname is Sunday

Shared Hosting
Rookie
Pro
Advanced
Dedicated Servers
BASE
BUSINESS
ENTERPRISE
Why Choose Brinkster?
Radical Support
Brinkster Datacenter
Brinkster Network
Corporate Social Responsibility
90 Day Money Back Guarantee
Unsurpassed Value
Client Testimonials
Additional Features
Antivirus
Merchant Account
E-Commerce
Live Chat Communicator
Free Firewall
Website Builder
Free Web Hosting
Support
General Support
Codebank Search
Forums
Articles
Click here for Brinkster Live Chat
Home   Domains   Shared Hosting   Dedicated Hosting   Partner   Support   About Us    Contact Us   Webmail
Copyright © Brinkster Communications Corporation All Rights Reserved. Privacy Policy & Legal