P parijs Active Member Licensed User Longtime User Feb 2, 2025 #1 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)
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)
Alexander Stolte Expert Licensed User Longtime User Feb 2, 2025 #2 parijs said: SetDate Click to expand... The SetDate function needs 3 parameters (Year, Month and Day) If you want to convert a date string to ticks, then use DateTime.DateParse: B4X: Copy Dim Date1 As Long = DateTime.DateParse(datumaanmaak) Upvote 0
parijs said: SetDate Click to expand... The SetDate function needs 3 parameters (Year, Month and Day) If you want to convert a date string to ticks, then use DateTime.DateParse: B4X: Copy Dim Date1 As Long = DateTime.DateParse(datumaanmaak)
P parijs Active Member Licensed User Longtime User Feb 2, 2025 #3 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
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)
Alexander Stolte Expert Licensed User Longtime User Feb 2, 2025 #4 please create an example project that shows your problem, I have no idea what your ElapsedDaysBetween2Dates function looks like. An example project would be best. Upvote 0
please create an example project that shows your problem, I have no idea what your ElapsedDaysBetween2Dates function looks like. An example project would be best.
P parijs Active Member Licensed User Longtime User Feb 2, 2025 #5 example Attachments TEST.zip TEST.zip 12.2 KB · Views: 291 Upvote 0
Alexander Stolte Expert Licensed User Longtime User Feb 2, 2025 #6 parijs said: my code gives 50 days and it should be 71 Click to expand... 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
parijs said: my code gives 50 days and it should be 71 Click to expand... 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.
P parijs Active Member Licensed User Longtime User Feb 2, 2025 #7 You're right sorry didn't see it. Thanks again Upvote 0