How to get every second date from the list of datetimes

Hi,
I have a list of datetimes and i’d have to define every second item in this list to “first day” and the rest “last day”. So in the end i’d have two different lists. How do i achieve this. Googled about mod2 method that could be handy here, but cannot get it to work… :slight_smile:

hi @Mikko_S

below snippet can help you to do the operation.

i am just storing the index of the each item in a variable and calculating the MOD of the variable with 2.

instead of message box you can use the Add to collection activity to separate the date as two different list.

Regards
Ajay

1 Like

@Mikko_S,

You can try something like this,

 Dim oddCategories = projectsByCat.Where(Function(cat, index) index Mod 2 = 0)
    Dim evenCategories = projectsByCat.Where(Function(cat, index) index Mod 2 <> 0)
2 Likes

Thanks. Both solutions work. Great help! :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.