Android Question Convert from milliseconds to days

Isac

Active Member
Licensed User
Longtime User
Hello,

How do I convert milliseconds into days?

I want to insert into the editbox day.

example: if I want a delay of 1 day I want to insert 1 is not in milliseconds

Thanks for the help



B4X:
Sub Button2_Click
    timer1.Initialize("Timer1",EditText3.Text)
    timer1.Enabled=True
End Sub
 
Last edited:

Isac

Active Member
Licensed User
Longtime User
When you select a date I would like the program tells me after X days.

These days I want to put them in a late X editbox.

I'm interested in an early example of this

when I press button2 the date must not appear immediately in the editbox but there must be a delay of x days.
I can not create this delay.

thanks



B4X:
Sub Button1_Click                           
Dim j As String
Dim dd As DateDialog
dd.ShowCalendar=False
DateTime.DateFormat=("dd/MM/yyyy")
dd.Year = DateTime.GetYear(DateTime.Now)
dd.Month = DateTime.GetMonth(DateTime.Now)   
dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
dd.Show("Inserisci la data", "Data", "OK", "", "", Null)
j = DateTime.Date(dd.DateTicks)
EditText2.Text=j
 
End Sub


B4X:
Sub Button2_Click
Dim p As Period
 
p.Days= EditText3.Text
Dim nuovadata As  Long =dateutils.AddPeriod(DateTime.Now,p)
Log(DateUtils.TicksToString(nuovadata))
 
DateTime.DateFormat=("dd/MM/yyyy")
    d=DateTime.Date(DateTime.now)
    EditText1.text=d
    If EditText1.text=EditText2.Text Then
    T.Vibrate(1000)
    End If 
End Sub
 
Last edited:
Upvote 0

Isac

Active Member
Licensed User
Longtime User
Erel you can give me a hand? :)

thanks







B4X:
Sub Button1_Click  
 
Dim today As String=DateTime.date(DateTime.Now)
edittext4.Text=today
Dim p As Period
 
p.Days=EditText1.Text
 
Dim date As Long= DateUtils.AddPeriod(DateTime.Now,p)
 
StartServiceAt(start,DateTime.Now+edittext1.Text,False)
 
                                      
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I think you are mixing long with int:
This line:
B4X:
StartServiceAt(start,DateTime.Now+edittext1.Text,False)
should be:
B4X:
StartServiceAt(start,date,False)
 
  • Like
Reactions: eps
Upvote 0

Isac

Active Member
Licensed User
Longtime User
when I try to compile and I press the button1 the program closes
I would like to figure out how to insert the delay

thank you all


B4X:
Sub Button1_Click  
 
Dim today As String=DateTime.date(DateTime.Now)
EditText4.Text=today
Dim p As Period
 
p.Days=EditText1.Text
 
Dim date As Long= DateUtils.AddPeriod(DateTime.Now,p)
 
StartServiceAt(start,date,False)
 
Last edited:
Upvote 0
Top