I have a SQL query which converts a date/timestamp column in my DB from a UNIX timestamp to a readable format. This gives me a nice readable format, but I want to drop the actual timestamp and keep the date only.. As I'm trying to count and group all occurrences of the date only.
SELECT DATEADD(ss,msg.timestamp/1000,'01/01/1970')As DateTime
FROM dbo.cp_messages msg
Result currently looks like this:
2005-10-26 11:12:36.000
But I would like :
2005-10-26
How do I drop the time.
The comments have helped, but how do I search between dates now that I'v converted the unix time into the correct format.. I've tried the below but get errors everytime.
SELECT COUNT(msg.messageId)
,CONVERT(VARCHAR(10), DATEADD(ss, msg.[timestamp]/1000, '01/01/1970'), 120)
FROM dbo.cp_messages msg
WHERE timestamp >= DATEADD(DAY, -2, GETDATE())
GROUP BY timestamp
I seem to end up with a count for every instance, but what I'm after is a total count for that day..
Eg
1 2015-10-29
1 2015-10-29
1 2015-10-29
When I would like
3 2015-10-29
Not sure how to get the desired result