본문 바로가기
카테고리 없음

[vb.net] DateAndTime.DateDiff 메서드를 활용한 시간 계산

by IT HUB 2020. 9. 6.
728x90
반응형

Example:

DimDAsDate=DateValue(GetSetting("cp","api","searchDate","1999-01-01 01:01:01"))+TimeValue(GetSetting("cp","api","searchDate","1999-01-01 01:01:01"))

IfD>NowThen

DimMinutesAsLong=DateDiff(DateInterval.Minute, Now, D)

MsgBox(Minutes&"분 후에 검색해 주세요.")

Return

EndIf

아래 링크 참고:

DateDiff지정 된 날짜와 오늘 사이의 일 수:

Dimdate2EnteredAsString=InputBox("Enter a date")

 

Try

Dimdate2AsDate=Date.Parse(date2Entered)

Dimdate1AsDate=Now

 

' Determine the number of days between the two dates.

DimdaysAsLong=DateDiff(DateInterval.Day, date1, date2)

 

' This statement has a string interval argument, and

' is equivalent to the above statement.

'Dim days As Long = DateDiff("d", date1, date2)

 

MessageBox.Show("Days from today: "&days.ToString)

Catch exAsException

MessageBox.Show("Invalid Date: "&ex.Message)

EndTry

반응형


댓글