MyTetra Share
Делитесь знаниями!
первый/последний день недели
Время создания: 28.05.2021 23:08
Текстовые метки: день недели
Раздел: Разные закладки - VBA - Операции с датами-временем
Запись: xintrea/mytetra_db_adgaver_new/master/base/1622232527l62dxpxlq7/text.html на raw.githubusercontent.com

'первый день недели(FirstDayInWeek)

Function fun_FirstDayInWeek(ByVal dDate As Date) As Date

Dim intDay As Integer


If TypeName(dDate) = "Date" Then

intDay = DatePart("w", dDate, 0, 0)

fun_FirstDayInWeek = Format(dDate - intDay + 1, "DD.MM.YYYY")

End If

End Function

'последний день недели(LastDayInWeek)

Function fun_LastDayInWeek(ByVal dDate As Date) As Date

Dim intDay As Integer


If TypeName(dDate) = "Date" Then

intDay = DatePart("w", dDate, 0, 0)

fun_LastDayInWeek = Format(dDate + 7 - intDay, "DD.MM.YYYY")

End If

End Function

'последний день месяца

Function fun_LastDayInMonth(ByVal dDate As Date) As Date

Dim intDay As Integer

Dim intYear As Integer

Dim intMonth As Integer


If TypeName(dDate) = "Date" Then

intMonth = Month(dDate) + 1

intYear = Year(dDate)

If intMonth = 13 Then

intMonth = 1

intYear = intYear + 1

End If

fun_LastDayInMonth = DateSerial(intYear, intMonth, 0)

' fun_LastDayInMonth = Day(lastDate) '31

End If

End Function

 
MyTetra Share v.0.65
Яндекс индекс цитирования