月末の日付(末日)を取得する

カテゴリ: VB6.0
投稿日時:2009/01/05 16:26:01
月末の日付(末日)を取得するには以下のようにします。

Private Sub Command1_Click()

    '月末を取得したい日付
    Dim dat As Date
    
    dat = Text1.Text
    
    '月末を取得する
    Dim endDate As Date
    
    '1.翌月の月初を求める
    endDate = Format(DateAdd("m", 1, dat), "yyyy/mm/01")
    '2.月初の1日前は月末
    endDate = DateAdd("d", -1, endDate)
    
    MsgBox Text1.Text & "の月末は" & endDate & "です"
End Sub
このエントリーをはてなブックマークに追加

スポンサード リンク