Daily Newbie - 05/01/2001
“To Start Things
"Part of a Date"
Getting a part of a date value (i.e. Day, Month, Year, etc.).
VB Help Description: Returns a Variant (Integer) containing the specified part of a given date.
English: Lets you get only one part of a date/time value. For example you can determine what weekday a certain date falls on.
Syntax: Val=DatePart(Part, Date)
Usage:intWeekDay = DatePart("w","01/12/2000")
If you have not read the Daily Newbie on how VB stores date format, you may want to review it now by clicking here.
Part - The part of the date you want returned . This can be:
Date - The date that the part is derived from.
s - Seconds
n - Minutes
h - Hours
d - Days
y - Day of Year
w - Weekday
w - Week
m - Months
q - Quarter
yyyy - Year
To get the current week within the current year (What week is this for the year? 1-52 )):
MsgBox DatePart("ww", Date)
Today's code snippet returns the Julian date for today.
Copy & Paste Code:
MsgBox "Today's Julian Date is: " & DatePart("y",Date) & "/" & DatePart("yyyy",Date)