| estrazione | comando VBA |
| Mese | Month(data) |
| Anno | Year(data) |
| Giorno | Day(data) |
| Ore | Hour(data) |
| Minuti | Minute(data) |
| Secondi | Second(data) |
| Giorno della settimana | WeekDay(data) |
esempio:
Dim oggi As Integer
Dim giorno(7) As String
giorno(1) = "Lunedì"
giorno(2) = "Martedì"
giorno(3) = "Mercoledì"
giorno(4) = "Giovedì"
giorno(5) = "Venerdì"
giorno(6) = "Sabato"
giorno(7) = "Domenica"
Case 1 To 7: MsgBox ("Oggi é:" & giorno(oggi))End Select
sintassi:
DatePart(parametro, valore)
parametri:
esempi:
DatePart("h", Time) estraggo solo ora attuale
DatePart("yyyy", "15/10/2012") 2012
DatePart("m", "15/10/2012") 10
DatePart("d", "15/10/2012") 15
esempio: scrivo nel file un testo diverso se siamo prima delle 13 o dopo
If DatePart("h", Time) < 13 Then
Print #numerofile, "Buongiorno,"Else
Print #numerofile, "Buonasera,"End If