DatePart Function
DatePart 함수는 날짜의 특정 부분을 반환합니다.
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
반환 값:
The extracted part for the given date.
interval - A string expression from the following table, specifying the date interval.
interval (string value)
|
설명
|
yyyy
|
연도
|
q
|
분기
|
m
|
월
|
y
|
일
|
w
|
요일
|
ww
|
주
|
d
|
날짜
|
h
|
시
|
n
|
분
|
s
|
초
|
date - The date from which the result is calculated.
Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:
-
#yyyy-mm-dd#
-
#mm/dd/yyyy#
firstdayofweek: An optional parameter that specifies the starting day of a week.
firstdayofweek value
|
설명
|
0
|
시스템 기본값 사용
|
1
|
일요일(기본값)
|
2
|
월요일
|
3
|
화요일
|
4
|
수요일
|
5
|
목요일
|
6
|
금요일
|
7
|
토요일
|
firstweekofyear: An optional parameter that specifies the starting week of a year.
firstweekofyear value
|
설명
|
0
|
시스템 기본값 사용
|
1
|
1월 1일이 포함된 주(기본값)가 주 1입니다.
|
2
|
해당 연도의 4일 이상이 포함된 첫째 주가 주 1입니다.
|
3
|
새로운 연도의 날짜만 포함된 첫째 주가 주 1입니다.
|
Sub example_datepart
MsgBox DatePart("ww", #12/31/2005#)
MsgBox DatePart(date:=#1999-12-30#, interval:="q")
End Sub