Public Sub RefreshAllQuarterToDate()

Dim qtr As Long
Dim tdy As Date
Dim qtrStart As Date

' This is the current date; VBA's verison of Excel's TODAY() worksheet function.
tdy = DateTime.Date

' If we're using this model on the weekend, adjust back to Friday
Select Case DateTime.Weekday(tdy)
Case vbSaturday
tdy = tdy - 1
Case vbSunday
tdy = tdy - 2
End Select

' The numeric calendar quarter, e.g., September 30th -> 3; October 1st -> 4
qtr = Application.WorksheetFunction.Ceiling_Precise(DateTime.Month(tdy) / 3)

' A date that represents the first day of the current calendar quarter
qtrStart = DateTime.DateSerial(DateTime.Year(tdy), (qtr * 3) - 2, 1)

' The in-cell SQL statements in our workbook have a 'between' constraint in their
' 'where' clause that references these two input cells named 'start_date' and
' end_date'. E.g.,
' {select ... from tbl where biz_date between $start_date and $end_date}
' Here we fill in those two dates with our computed first and last dates of the
' current calendar quarter
With ThisWorkbook.Worksheets("query params")
.Range("start_date").Value = qtrStart
.Range("end_date").Value = DateTime.DateAdd("m", 3, qtrStart) - 1
End With

' If your in-cell SQL is (exclusively) in the plain text style, this line is not
' necessary. But if you have constructed in-cell SQL with formulas, we have to
' calculate so that the formulas react to the new start_date and end_date values
' we set above in our 'query params' sheet.
Application.Calculate

' We find and run all the in-cell SQL statements in the workbook which contains
' this code itself; this also updates your sheets with the resultsets.
OxlSnowflake.RunParallelAllInWorkbook ThisWorkbook

End Sub