So the spell will need to have been cast twice since the task takes longer than the spell. Did the check occur in the first minute, the second minute, or in the space of time between the end of one spell and the beginning of the next?
No it won't. Once the task is started, you can trigger the spell effect to use it before the roll, as per the spell as written. There is nothing written anywhere that says that the spell will need to be up for the entire duration. This is your ruling for how it works in your game, not how it works RAW.
The rules don't say. It just says that once before the spell ends, the target can roll a d4 and add the number rolled to one ability check of its choice, before or after making the check. The spell then ends. Since an ability check requires that a task is being performed, that reads to me that the task needs to be started and completed within the duration of the spell or else you are choosing when the ability check takes place in the fiction, when it doesn't actually take place in the fiction at all.
Except that completing the task simply is not required. Once before the spell ends, such as during a task that hasn't completed yet, you can add d4 to the roll when the check is made. That d4 can be added before the roll, such as halfway through the task, and it will be present once the check is called for.
Doing it that way I have just laid out satisfies the following.
1. Once before the spell ends, the target can roll a d4 and add the number rolled to one ability check o f its choice.
2. It can roll the die before or after making the ability check.
3. The spell then ends.
There is no requirement to complete the task before the spell ends for all of the above to be true.
(Side question: What would be the benefit of rolling the d4 before the check as the spell allows?)
Rolling before or after will almost always be irrelevant, so the benefit of rolling before will be the same as rolling after. You only have 1 minute and it will be unlikely that you will be performing multiple ability checks in that time frame that will need the d4, and if you do, you can just cast the spell again.
I don't buy that. At best this is trying to sneak the ability check into the fiction through the back door in my view with language games. It's a mechanic we use at the table for the DM to decide what happens in the fiction, not a thing that happens in the fiction itself.
You're arguing that there is no skill being used in the game world, when there is. If you are using a skill, then that skill can succeed or fail. That chance to succeed or fail is a "check"(for lack of a better term) in the game world. The mechanic just models that in-fiction "check."
It does matter if the task takes longer than the spell's duration.
You have yet to provide a reason for that other than, "Because when taking the rules as a whole into account, it follows that the task must be started and finished within the duration of the spell."
That is just your opinion on what the rules show, and not one that is backed up by the actual rules from what I can see.