Hi, is there a way to have a Date/Time chooser so I can limit user to only choose a timeframe within the past 24 hours?
Last edited:
Did you tried the method "is24HourMode"?How can i configure that library so it's only selectable within 24 hours?
One way to do this is to check if the date and time you get from the date picker falls within the last 24 hours:Hi, is there a way to have a Date/Time chooser so I can limit user to only choose a timeframe within the past 24 hours?
Log(ValidateDate("1/16/2018","15:40:12") ) 'returns true code run 1/16/2018 around 19:30
Log(ValidateDate("1/15/2018","15:40:12") ) 'returns false
Log(ValidateDate("1/17/2018","9:45:17") ) 'returns false
Log(ValidateDate("1/16/2018","1:05:07") ) 'returns true
Sub ValidateDate(MyDate As String, MyTime As String) As Boolean
Dim p As Period
p.Days = -1
Dim DateStart As Long = DateUtils.AddPeriod(DateTime.Now, p)
Dim DateEnd As Long=DateTime.Now
Dim DT As Long=DateTime.DateTimeParse(MyDate,MyTime)
If DT>=DateStart And DT<=DateEnd Then Return True Else Return False
End Sub[/code
You can modify the code if the date you extract from picker is in ticks or you are only dealing with a date and no time.
This is how I would then do it. Hope this is compatible with your preference:However the result it returns the date/time separately as: year, month, day, hour, minute
Log(ValidateMyDate(2018,1, 23, 17, 10, 0) ) 'true code run around 6 PM EST
Log(ValidateMyDate(2018,1, 22, 17, 10, 0) ) 'false
Log(ValidateMyDate(2018,1, 23, 1, 0, 0) ) 'true
Sub ValidateMyDate(y As Int,m As Int, d As Int, h As Int, n As Int, s As Int) As Boolean
Dim p As Period
p.Days = -1
Dim DateStart As Long = DateUtils.AddPeriod(DateTime.Now, p)
Dim DateEnd As Long=DateTime.Now
Dim DT As Long=DateUtils.SetDateAndTime(y,m,d,h,n,s)
If DT>=DateStart And DT<=DateEnd Then Return True Else Return False
End Sub
I have been testing your code for a while now. It has been working great so far. Thank you!
Sub ValidateMyDate(y As Int,m As Int, d As Int, h As Int, n As Int) As Boolean
.
.
Dim DT As Long=DateUtils.SetDateAndTime(y,m,d,h,n,0)