0

I have database in Access and a Visual Studio WPF application. I want to create a query that treat only to hours (I mean that I don't care the date month/day/year -> I care only the hours. )

I create bar Chart that contain bars hours :

00:00:00 - 00:59:59 is the first bar
01:00:00 - 01:59:59 is the second bar
.
.
.
.
.
23:00:00 - 23:59:59 is the last bar

My try :

SELECT 
    Accurty
FROM 
    Ikun 
WHERE 
    Fall_Time >= '{*/*/* 00:00:00}' and Fall_Time <= '{*/*/* 00:59:59}'"

The result I want to get is a table that should be look like this : After query that gives the Accurty from the hours 10:00:00 - 10:59:59 for example :

My data base :

Number   Fall Time                     Acurrty
-------------------------------------------------------
1           01/01/2010 10:00:00          0.3   
2           15/03/2011 10:30:00          0.123   
3           31/01/1994 11:00:00          0.2   

Result :

     Acurrty
-----------------
      0.3   
      0.123   
Tanner
  • 22,205
  • 9
  • 65
  • 83
HardQS
  • 23
  • 6
  • Can you post test data and the expected output ? – Mahesh Feb 16 '15 at 10:14
  • I have been wrote it, the post data is a table that contain field "Fall_Time". I want to select from the table this field and get the tha Accurty in that time. – HardQS Feb 16 '15 at 10:43
  • See in [this question](http://stackoverflow.com/questions/28305644/sql-server-query-correlation-from-two-tables/28305725#28305725) how the post data is included in question try including the same way in your question with what output data do you expecting. – Mahesh Feb 16 '15 at 10:46
  • I editted the question, take a look please. – HardQS Feb 16 '15 at 10:52
  • Are you sure that's what you want ? As per your description you want `00:00` to `00:59` so in that way `10:00`-`10:59` should be (`0.3`/`0.123`) and `11:00`to `11:59` should be `0.2` – Mahesh Feb 16 '15 at 10:54
  • Yes that what I mean, I want in the resualt table the 0.3 as a first line and 0.123 as a second line. I dont care about the year/month/day only the hours. how can I do it ? – HardQS Feb 16 '15 at 10:58
  • @HardQS use dateandtime part function in your query – Dhru 'soni Feb 16 '15 at 11:02
  • http://stackoverflow.com/questions/12354699/time-part-of-a-datetime-field-in-sql @HardQS go through this and this https://msdn.microsoft.com/en-IN/library/ms174420.aspx – Dhru 'soni Feb 16 '15 at 11:02
  • Dhru I didn't understand from this sorry. Can you just help me to write the query ? I dont know how to ignore the year/month/day and to take care only to hours/min/sec – HardQS Feb 16 '15 at 11:12
  • possible duplicate of [Access query to get rows for a range of times (disregarding date)](http://stackoverflow.com/questions/28542022/access-query-to-get-rows-for-a-range-of-times-disregarding-date) – Gord Thompson Feb 16 '15 at 13:54

1 Answers1

0

SELECT Accurty FROM Ikun WHERE Fall_Time IN (SELECT Fall_Time FROM Ikun GROUP BY HOUR(Fall_Time) HAVING HOUR(Fall_Time)=0);

OR Try bellow

SELECT Accurty FROM Ikun WHERE Fall_Time IN (SELECT Fall_Time FROM Ikun GROUP BY TIME(Fall_Time) HAVING TIME(Fall_Time) BETWEEN '00:00:00' AND '00:59:59');

Check if this works

  • I dont need the accurty group by the hour of fall_time. I need the accurty between 2 hours falltime . – HardQS Feb 16 '15 at 11:59
  • Your second query sounds good but doesn't works. It does error about the numbers arguments in this query. – HardQS Feb 16 '15 at 12:12