Android Question DateUtils with variable problem

parijs

Active Member
Licensed User
Longtime User
The first code works

Dim Date1 As Long = DateUtils.SetDate(2025, 1, 26)

But if I want to use a variable I get the following error ',' expected.

Tried a few things but not the right one.

Dim Date1 As Long = DateUtils.SetDate(datumaanmaak)
 
Thanks Alexander it works now with variables
my code gives 50 days and it should be 71.

DateTime.DateFormat = "dd-MM-yyyy"
datumaanmaak ="30-6-2024"
datum7="20-4-2024"

Dim Date1 As Long = DateTime.DateParse(datum7)
Dim Date2 As Long = DateTime.DateParse(datumaanmaak)

Dim ID As B4XSet = B4XCollections.CreateSet2(Array(2, 3, 4, 5, 6)) ' Number of days excluding Sunday and Saturday
Dim WorkingDays As Int = ElapsedDaysBetween2Dates(Date1, Date2, ID)
DateTime.DateFormat = "dd-MM-yyyy"
Log(WorkingDays)
 
Upvote 0
my code gives 50 days and it should be 71
But 50 is right, you leave out all Saturdays and Sundays?
You even wrote it as a comment:
B4X: Copy
Dim ID As B4XSet = B4XCollections.CreateSet2(Array(2, 3, 4, 5, 6)) ' Number of days excluding Sunday and Saturday

What is your problem?
if I add the 1 and 7 to the array then 71 comes out.
 
Upvote 0
Back
Top