dateutils problem

dgoss

Member
Licensed User
Longtime User
having probs with dateutils addperiod.

Code
B4X:
Sub restBefore
Dim RestTime As Long
RestTime = DateTime.now
If Start9 = True Then
   p.Hours = 9:p.Minutes =5
      Dim newdate As Long = DateUtils.AddPeriod(RestTime,p)
         Log(DateUtils.TicksToString(newdate))
Else
p.Hours = 4:p.Minutes =30
Dim newdate As Long = DateUtils.AddPeriod(RestTime,p)
Log(DateUtils.TicksToString(newdate))

End If
   
End Sub
this the log details

** Activity (main) Resume **
20130623 03:42:06 first part
06/23/2013 04:06:59 second part

just noticed that the first part is the date but not formated like second part

the first part of the if statement (Start9 = true) return long date but correct time.The second part returns correct date and time.
Any help really appreciated as need this to work to try and finish of my project.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Can you post the full code?

Note that your code can be written more "elegantly":
B4X:
Sub restBefore
Dim RestTime As Long
RestTime = DateTime.now
If Start9 = True Then
    p.Hours = 9:p.Minutes =5
Else
     p.Hours = 4:p.Minutes =30
End If
Dim newdate As Long = DateUtils.AddPeriod(RestTime,p)
Log(DateUtils.TicksToString(newdate))
End Sub
 
Upvote 0

dgoss

Member
Licensed User
Longtime User
Hi Erel

tried to upload file but to big. Trying to emulate it in a smaller file but no success yet
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
At the point at which you define or alter start9 variable, do you have any date.dateformat used?
 
Upvote 0

dgoss

Member
Licensed User
Longtime User
hi Mc73

thx for that insight for dateformat tried and now works fine.
I must admit i did not think i would have to set date format.


tis the little things in life that take the longest to find
(quote from the misses)
 
Upvote 0
Top