VBA

日付クラス

''' <summary>
''' Year 関数
''' </summary>
''' <param name="Expression">日付</param>
''' <reterns>年</reterns>
''' <see>https://learn.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/year-function</see>
Public Function IntYear(ByVal Expression As Variant) As Variant
    IntYear = Year(Expression)
End Function

''' <summary>
''' Month 関数
''' </summary>
''' <param name="Expression">日付</param>
''' <reterns>月</reterns>
''' <see>https://learn.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/month-function</see>
Public Function IntMonth(ByVal Expression As Variant) As Variant
    IntMonth = Month(Expression)
End Function

''' <summary>
''' Day 関数
''' </summary>
''' <param name="Expression">日付</param>
''' <reterns>日</reterns>
''' <see>https://learn.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/day-function</see>
Public Function IntDay(ByVal Expression As Variant) As Variant
    IntDay = Day(Expression)
End Function

曜日

''' <summary>
''' Weekday 関数
''' </summary>
''' <param name="Expression">日付</param>
''' <reterns>曜日</reterns>
''' <see>https://learn.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/weekday-function</see>
Public Function IntWeekday(ByVal Expression As Variant) As Variant
    IntWeekday = Weekday(Expression)
End Function

日付フォーマット

''' <summary>
''' FormatDateTime 関数
''' </summary>
''' <param name="Expression">日付</param>
''' <param name="NamedFormat">書式</param>
''' <reterns>式</reterns>
''' <see>https://learn.microsoft.com/ja-jp/office/vba/language/reference/user-interface-help/formatdatetime-function</see>
Public Function StrFormatDateTime(ByVal Expression As Variant, Optional ByVal NamedFormat As VbDateTimeFormat = vbGeneralDate) As String
    StrFormatDateTime = FormatDateTime(Expression, NamedFormat)
End Function

コメント