Field, date truncate method
This commit is contained in:
10
pgm_field.go
10
pgm_field.go
@@ -131,6 +131,16 @@ func (f Field) IsNotNull() Conditioner {
|
||||
return &Cond{Field: col, op: " IS NOT NULL", len: len(col) + 12}
|
||||
}
|
||||
|
||||
// DateTrunc will truncate date or timestamp to specified level of precision
|
||||
//
|
||||
// Level values:
|
||||
// - microseconds, milliseconds, second, minute, hour
|
||||
// - day, week (Monday start), month, quarter, year
|
||||
// - decade, century, millennium
|
||||
func (f Field) DateTrunc(level, as string) Field {
|
||||
return Field("DATE_TRUNC('" + level + "', " + f.String() + ") AS " + as)
|
||||
}
|
||||
|
||||
// EqualFold will use LOWER(column_name) = LOWER(val) for comparision
|
||||
func (f Field) EqFold(val string) Conditioner {
|
||||
col := f.String()
|
||||
|
||||
Reference in New Issue
Block a user