Skip to content

Commit

Permalink
Fixing MSSQL timestamp type (#5511)
Browse files Browse the repository at this point in the history
MSSQL is using the wrong type here which results in a strconv.ParseInt: parsing "2018-12-07T00:00:00Z": invalid syntax error.
The added datediff(SECOND, '19700101', x) results in the unix timestamp to be returned.

Signed-off-by: Christopher Dziomba <[email protected]>
  • Loading branch information
chdxD1 authored and lunny committed Dec 11, 2018
1 parent 205a533 commit 64680b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion models/user_heatmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func GetUserHeatmapDataByUser(user *User) ([]*UserHeatmapData, error) {
case setting.UsePostgreSQL:
groupBy = "extract(epoch from date_trunc('day', to_timestamp(created_unix)))"
case setting.UseMSSQL:
groupBy = "dateadd(DAY,0, datediff(day,0, dateadd(s, created_unix, '19700101')))"
groupBy = "datediff(SECOND, '19700101', dateadd(DAY, 0, datediff(day, 0, dateadd(s, created_unix, '19700101'))))"
groupByName = groupBy
}

Expand Down

0 comments on commit 64680b7

Please sign in to comment.