MyTetra Share
Делитесь знаниями!
Как найти первый и последний день указанной недели, месяца или года в Access 2010.txt
16.03.2019
23:43
Текстовые метки: первый и последний день указанной недели
Раздел: !Закладки - VBA - Разобрать

https://msdn.microsoft.com/ru-ru/library/office/hh134613(v=office.14).aspx


'=======================================================================================

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

Function funFirstDayInWeek(ByVal dDate As Date) As Date

Dim intDay As Integer


If TypeName(dDate) = "Date" Then

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

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

End If

End Function

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

Function funLastDayInWeek(ByVal dDate As Date) As Date

Dim intDay As Integer


If TypeName(dDate) = "Date" Then

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

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

End If

End Function

'=======================================================================================



VBA

? FirstDayInMonth(#2/15/2012#)


? LastDayInMonth(#2/15/2012#)


? FirstDayInWeek


? LastDayInWeek


? FirstDayInYear(Date)


? LastDayInYear(Date)


SQL

SELECT DateTable.TestDate,

FirstDayInMonth([TestDate]) AS FirstDayInMonth,

LastDayInMonth([TestDate]) AS LastDayInMonth,

FirstDayInYear([TestDate]) AS FirstDayInYear,

LastDayInYear([TestDate]) AS LastDayInYear,

FirstDayInWeek([TestDate]) AS FirstDayInWeek,

LastDayInWeek([TestDate]) AS LastDayInWeek

FROM DateTable;


Public Function FirstDayInMonth(Optional dtmDate As Variant) As Date

If IsMissing(dtmDate) Then

dtmDate = Date

End If

FirstDayInMonth = DateSerial( _

Year(dtmDate), Month(dtmDate), 1)

End Function


FirstDayInMonth = DateSerial( _

Year(dtmDate), Month(dtmDate), 1)

Так же в этом разделе:
 
MyTetra Share v.0.52
Яндекс индекс цитирования