模型时 gorm 的 gen 工具自动生成的:
Date time.Time `gorm:"column:date;type:date;not null;comment:日期" json:"date"`
生成的查询
`date` = '2023-11-07 08:00:00' LIMIT 1
要怎么设置才能生成日期格式时2023-11-07
的正确查询?
1
gouguoyin 352 天前
|
2
pkoukk 352 天前
dsn 里加上 parseTime=True&loc=Local
|
3
body007 351 天前
直接用字符串呗,不一定非要传 time.Time 对象吧。
db.Debug().Model(&Data{}).Where("date = ?", time.Now().Format(time.DateOnly)).Limit(5).Find(&data) |