1

I'm using SQL Server and I need to SELECT timestamp that return only data on every full hour. So now I get:

timestamp                  value
2019-12-18 17:00:00.000    0
2019-12-18 17:05:00.000    0
2019-12-18 17:10:00.000    0
2019-12-18 17:15:00.000    0
2019-12-18 17:20:00.000    1,5
2019-12-18 17:25:00.000    1,5
2019-12-18 17:30:00.000    0
2019-12-18 17:35:00.000    0   
2019-12-18 17:40:00.000    0 
2019-12-18 17:45:00.000    0
2019-12-18 17:50:00.000    0
2019-12-18 17:55:00.000    0
2019-12-18 18:00:00.000    0,6

but i need

timestamp                  value
2019-12-18 17:00:00.000    0
2019-12-18 18:00:00.000    0,6

Can somebody help me?

Dale K
  • 25,246
  • 15
  • 42
  • 71
bobialen
  • 109
  • 1
  • 1
  • 7

1 Answers1

0

Something like this should work

SELECT timestamp ,
       value
FROM   myTable 
WHERE  DATEPART(MINUTE, timestamp) = 0;

If you want to check that the seconds and milliseconds are 0 too:

SELECT timestamp ,
       value
FROM   myTable
WHERE  DATEPART(MINUTE, timestamp) = 0
       AND DATEPART(ss, timestamp) = 0
       AND DATEPART(ms, timestamp) = 0;
Erfan Mohammadi
  • 424
  • 3
  • 7
donaldsa18
  • 302
  • 1
  • 4