Usually, a
hefsek taharah performed after
sh'kiah only counts for the next day (for example a
hefsek taharah on Wednesday evening after
sh'kiah would be valid for Thursday but not for Wednesday). In cases in which the timing is very close, such as yours, there may be room for leniency when there is a major extenuating factor, such as fertility or shalom bayit issues.
Additionally, if a
bedikah is performed earlier in the day, before a planned
hefsek taharah, it usually can count after the fact as a
hefsek taharah for that day. In some cases, using a tampon or something similar might also have halachic weight.
In fact, we recommend that women perform a
bedikah earlier in the day, before a planned
hefsek taharah, in order to have a fall back option in situations such as these.
Please write back to us with any follow up questions.