Var ldDateFrom As DateTime
Var ldDateTo As DateTime
Var ldToFilterDate As DateTime
Var ldTargetDate As DateTime
ldToFilterDate = DateTime.FromString(txtTarget.Value) //contains a SqlDate 2020-05-05
// First of this month at midnight
ldDateFrom = ldToFilterDate.SubtractInterval(0, 0, ldToFilterDate.Day - 1, _
ldToFilterDate.Hour, ldToFilterDate.Minute, ldToFilterDate.Second)

// This seems it would set it to 2020-05-04 I don’t understand this.

txtFirstOf.Text = ldDateFrom.SQLDate // Show 2020-05-01 Why

Surely 2020-05-05 minus 4 days and some amount of time is 2020-05-01. (Whatever the time values got set to in ldToFilterDate, you subtracted them exactly.)

ldToFilterDate.Day is using the ‘day’ part of the original SQLDate value, for this example 5
SubtractInterval has a calculation on the day section that say: ldToFilterDate.Day - 1
So every time you use that calculation it will subtract the number of days -1. If ldToFilterDate.Day is 20, it will subtract 19, if it is 5 it will subtract 4 and so on.