Android Question Date and time functions

rleiman

Well-Known Member
Licensed User
Longtime User
Hi,

Does B4A have a time function where I can construct an if statement that looks like this?

B4X:
If TimeIsInBetween(Start, End) = True Then
   Do something
End If

Thanks.
 

Mahares

Expert
Licensed User
Longtime User
Does B4A have a time function where I can construct an if statement that looks like this?
Are you looking for something like this Mr. NE Patriots fan?
B4X:
Log(TimeIsBetween("11/30/2016 4:50" ,"11/30/2016 1:30","11/30/2016 6:13") )  'true
B4X:
Sub TimeIsBetween(TimeBetween As String,t1 As String, t2 As String) As Boolean
    Dim OrigDateFormat As String = DateTime.dateFormat
    DateTime.dateFormat = "MM/dd/yyyy HH:mm"
    Dim tbetween As Long=DateTime.DateParse(TimeBetween)
    Dim tstart As Long=DateTime.DateParse(t1)
    Dim tend As Long=DateTime.DateParse(t2)
    DateTime.dateFormat =OrigDateFormat
    If tbetween>=tstart And tbetween<= tend Then
        Return True
    Else
        Return False
    End If
End Sub
 
Upvote 0

Similar Threads

Top