, : ", 03--13 1- ". , , 2- , 1 - 6- , 3- 1- , , , 2- .
, , guitarthrower, rvalerio user3496574, , , . , 6, , 5 ( , , 4 ).
, . , . , 7 , 1- - - , 7, .
Excel - :
=ROUNDUP(DAY(MyDate)/7,0)
VBA , , , :
Function WeekOfMonth(TestDate As Date) As Integer
WeekOfMonth = Application.WorksheetFunction.RoundUp(Day(TestDate) / 7, 0)
End Function
, , , Excel, , , :
Function WeekOfMonth(TestDate As Date) As Integer
WeekOfMonth = RoundUpVBA(Day(TestDate) / 7,0)
End Function
Function RoundUpVBA(InputDbl As Double, Digits As Integer) As Double
If InputDbl >= O Then
If InputDbl = Round(InputDbl, Digits) Then RoundUpVBA = InputDbl Else RoundUpVBA = Round(InputDbl + 0.5 / (10 ^ Digits), Digits)
Else
If InputDbl = Round(InputDbl, Digits) Then RoundUpVBA = InputDbl Else RoundUpVBA = Round(InputDbl - 0.5 / (10 ^ Digits), Digits)
End If
End Function
, Excel 3496574, :
=WEEKNUM(MyDate) - WEEKNUM(EOMONTH(MyDate,-1)+1)+1
, VBA.
- , , , , .
Qaru VBA, . C++ , . , .
VBA, , , (, , , ).
, , , , VBA Round (round-half-even), Excel , CInt, - Int ( Fix), .
, Banker , , . , .5 , , . , , , , , . , , .
, , , .
Excel:
=ROUNDUP(((DAY(MyDate)+WEEKDAY(EOMONTH(MyDate,-1)+1)-1) / 7), 0)
, .
03--13 3 7 8 7. , 2 1.
VBA:
Function WeekOfMonth(TestDate As Date) As Integer
Dim FirstDayOfMonth As Date
Dim Offset As Integer
FirstDayOfMonth = TestDate - Day(TestDate) + 1
Offset = Weekday(FirstDayOfMonth)
WeekOfMonth = Application.WorksheetFunction.RoundUp((((Day(TestDate) + Offset) - 1) / 7), 0)
End Function
Exceljet .
, . , , :
=getWeekOfMonth(MyDate-WEEKDAY(EOMONTH(MyDate,-1)+1)+8)-1
, , VBA , . -:
WeekOfMonth = Day(TestDate) / 7 ' divide by 7
WeekOfMonth = Fix(WeekOfMonth - 0.0001) + 1 ' ugly rounding up
. , , 1 7 , , 1, 0.
:
WeekOfMonth = Day(TestDate) / 7 ' divide by 7
WeekOfMonth = Day(WeekOfMonth + 1.9999) ' uglier rounding up
, VBA - . ( , , , , VBA Excel .)
, Int , , , , CBool 0 , - , - . - .
, , :
Function WeekOfMonth(TestDate As Date) As Integer
Dim TempWeekDbl As Double
TempWeekDbl = Day(TestDate) / 7 ' divide by 7
TempWeekDbl = Fix(TempWeekDbl - 0.0001) + 1 ' ugly rounding up
WeekOfMonth = TempWeekDbl
End Function
, , , :
Function RoundUpToWhole(InputDbl As Double) As Integer
Dim TruncatedDbl As Double
TruncatedDbl = Fix(InputDbl)
If TruncatedDbl <> InputDbl Then
If TruncatedDbl >= 0 Then RoundUpToWhole = TruncatedDbl + 1 Else RoundUpToWhole = TruncatedDbl - 1
Else
RoundUpToWhole = TruncatedDbl
End If
End Function
RoundUpVBA, , Excel ROUNDUP, . Excel, ROUND .
, , , , , , 0,14 ( , 0,0001). , , . , , , .
.
I wonder if the famous last words were ever the famous last words?