speed-tester/database/helper.go

24 lines
489 B
Go

package database
func whereStatement(dateCol string, from string, to string) (string, []any) {
whereValues := []any{}
if from == "" && to == "" {
return "", whereValues
}
statement := "WHERE "
if from != "" {
statement += dateCol + " >= date(?) "
whereValues = append(whereValues, from)
}
if from != "" && to != "" {
statement += " AND "
}
if to != "" {
statement += dateCol + " <= date(?)"
whereValues = append(whereValues, to)
}
return statement, whereValues
}