DatePart Function
DatePart-funktio palauttaa päivämäärästä määrätyn osan.
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long
Palautusarvo:
The extracted part for the given date.
 interval - A string expression from the following table, specifying the date interval.
  
    | interval (string value) | Selitys | 
  
    | yyyy | Vuosi | 
  
    | q | neljännesvuosi | 
  
    | m | Kuukausi | 
  
    | y | (Vuoden) päivä | 
  
    | w | Viikonpäivä | 
  
    | ww | Vuoden viikkonumero | 
  
    | d | Päivä | 
  
    | h | tunti | 
  
    | n | minuutti | 
  
    | s | sekunti | 
 
 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 | Selitys | 
  
    | 0 | käyttöjärjestelmän oletusarvo | 
  
    | 1 | sunnuntai (oletus) | 
  
    | 2 | maanantai | 
  
    | 3 | tiistai | 
  
    | 4 | keskiviikko | 
  
    | 5 | torstai | 
  
    | 6 | perjantai | 
  
    | 7 | lauantai | 
 firstweekofyear: An optional parameter that specifies the starting week of a year.
  
    | firstweekofyear value | Selitys | 
  
    | 0 | käyttöjärjestelmän oletusarvo | 
  
    | 1 | viikolla, johon kuuluu 1. tammikuuta, on viikkonumero 1 (oletus) | 
  
    | 2 | vuoden ensimmäisellä sellaisella viikolla, jossa on päiviä neljä tai enemmän, on viikkonumero 1 | 
  
    | 3 | vuoden ensimmäinen kokonainen viikko, jossa on vain uuden vuoden päiviä, saa viikkonumero 1:n | 
 
Sub example_datepart
    MsgBox DatePart("ww", #01/02/2005#) ' displays 2 because weeks start on Sunday
    MsgBox DatePart("ww", #12/31/2005#) ' displays 53
    MsgBox DatePart(date:=#2005-12-30#, interval:="q") ' displays 4
End Sub