본문 바로가기

자료

[C#/vb.net] 두 날짜 및 시간 사이에(구간)에 지정한 특정 날자시간이 포함되는지 확인하는 함수

728x90

Private Function BetweenDate(StartTime As Date, EndTime As Date, CurrentTime As Date) As Boolean

If CurrentTime.Ticks >= StartTime.Ticks And CurrentTime.Ticks <= EndTime.Ticks Then

Return True

End If

Return False

End Function

 

 

사용예:)

If Not i.cName Is Nothing Then

ck = BetweenDate(i.sDate, i.eDate, DateTimePicker1.Value)

ck = ck Or BetweenDate(i.sDate, i.eDate, DateTimePicker2.Value)

End If

 

If ck Then

MsgBox("이미 예약된 시간입니다.")

Return

 

End If

728x90