Android Question SQLite Time Fuction Issue

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have sqlite database table that contain time field (14:25),I would like to add 10 minutes such as(14:35).
I have found a solution in internet to add Time using sqlite Time function Example

Select Time(14:25,'+10Minutes');

This function works fine on Android 2.2 Emulator but it return null value in Android 4.0 Device (Actual Device).Pls advise where it is problem...this is my serious problem that i am facing for last two days.

Pls help...........................................................

 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can implement it in your code instead:
B4X:
Sub AddMinutes(TimeString As String, add As Int) As String
   Dim i As Int = TimeString.IndexOf(":")
   Dim hours As Int = TimeString.SubString2(0, i)
   Dim minutes As Int = TimeString.SubString(i + 1)
   minutes = minutes + add
   hours = hours + minutes / 60
   minutes = minutes Mod 60
   Return NumberFormat(hours, 2, 0) & ":" & NumberFormat(minutes, 2, 0)
End Sub
(haven't tested the code...)
 
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
Thanks Erel,above code is working, Now I have solved my problem.Can u give me example code for Subtracting minutes..such as (06:01) should become (05:58).Eagerly waiting for your prompt reply.
 
Upvote 0
Top