Hi,
I am taking in a text input date in format yyyy-MM-dd hh:mm and compare it with current
system datetime to ascertain how many days, hours and minutes is the difference.
I attempted to convert both the system-system date and inputted date into
ticks before making the comparison.
I am attaching the relevant code..
This is not working..
The code and the error message is attached.
Please guide me in this regard.
Thanks.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I am taking in a text input date in format yyyy-MM-dd hh:mm and compare it with current
system datetime to ascertain how many days, hours and minutes is the difference.
I attempted to convert both the system-system date and inputted date into
ticks before making the comparison.
I am attaching the relevant code..
This is not working..
The code and the error message is attached.
Please guide me in this regard.
Thanks.
			
				B4X:
			
		
		
		Private Sub btnCompareDate_Click
xui.MsgboxAsync("To compare the dates","B4X")
    Dim f As Boolean
    Dim inputDate As String
    Dim d As Long
    Dim t As Long
    inputDate=txtInputDate.Text.Trim
    'first set the date format to the format in which the date is inputted in the text control viz. in dd/mm/yyy hh:mm
    DateTime.DateFormat = "yyyy-MM-dd hh:mm"
    d = DateTime.DateParse(inputDate)
    t = DateTime.Now '
    Log("Input date and time :" & d)
    Log("Current Date and Time:" & t)
    Log("Your Selected Date is " & DateTime.Date(d) & " " & "Current Date is " & DateTime.Date(t))
    If DateTime.Date(d) = DateTime.Date(t) Then
        xui.MsgboxAsync("The date and time match !","B4X")
        
    Else
        If DateTime.Date(d)< DateTime.Date(t) Then
        xui.MsgboxAsync("You have YET :" & DateTime.Date(t-d),"B4X")
        Else
        xui.MsgboxAsync("It is already PAST:" & DateTime.Date(d-t),"B4X")
        End If
    End If
End Sub
It gies this error..
b4xmainpage_btncomparedate_click (java line: 65)
java.text.ParseException: Unparseable date: "2025-02-08 00:05"
    at java.text.DateFormat.parse(DateFormat.java:362)
    at anywheresoftware.b4a.keywords.DateTime.DateParse(DateTime.java:148)
    at b4a.example.b4xmainpage._btncomparedate_click(b4xmainpage.java:65)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7189)
    at android.view.View.performClickInternal(View.java:7166)
    at android.view.View.access$3500(View.java:819)
    at android.view.View$PerformClick.run(View.java:27682)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7592)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		