0
두 개의 월요일 사이에 몇 개의 월요일이 있는지 확인하려고합니다. 이 날짜는 datetimepicker에 의해 삽입됩니다.한 달에 몇 달 만에 Visual Basic
나는 이와 비슷한 스레드가 있지만 모두 PHP 나 VBScript 인 것을 알고 있습니다.
아이디어가 있으십니까?
두 개의 월요일 사이에 몇 개의 월요일이 있는지 확인하려고합니다. 이 날짜는 datetimepicker에 의해 삽입됩니다.한 달에 몇 달 만에 Visual Basic
나는 이와 비슷한 스레드가 있지만 모두 PHP 나 VBScript 인 것을 알고 있습니다.
아이디어가 있으십니까?
이 게시물은 C#에서 수행하는 방법을 알려줍니다. Count number of Mondays in a given date range
아래 변환기를 통해 코드를 실행했습니다. 그것을 테스트하지 않았습니다.
Private Shared Function CountDays(day As DayOfWeek, start As DateTime, [end] As DateTime) As Integer
Dim ts As TimeSpan = [end] - start
' Total duration
Dim count As Integer = CInt(Math.Floor(ts.TotalDays/7))
' Number of whole weeks
Dim remainder As Integer = CInt(ts.TotalDays Mod 7)
' Number of remaining days
Dim sinceLastDay As Integer = CInt([end].DayOfWeek - day)
' Number of days since last [day]
If sinceLastDay < 0 Then
sinceLastDay += 7
End If
' Adjust for negative days since last [day]
' If the days in excess of an even week are greater than or equal to the number days since the last [day], then count this one, too.
If remainder >= sinceLastDay Then
count += 1
End If
Return count
End Function
제목에 "월별 한달"이 표시되지만 질문 문안에 "두 달 사이에 월요일에 몇 달이되는지"묻습니다. 어느 쪽이 원하는거야? –
이 두 날짜는 월과 끝의 시작입니다. – Carlos1