I can’t get the date on the chart

Asked

Viewed 38 times

-2

I’m doing the following command:

SELECT h.h_dia FROM hh h WHERE h.h_dia = 20180621 GROUP BY h.h_dia
  • if the format of the h_dia field is DATE and not INT try changing the date filter to: h.h_dia = '2018-06-21'

  • Returns nothing from table

  • 1

    How is the value in the h_dia column? And what is the type of the column in the table?

  • 2017-07-03 08:00:00 so for example

1 answer

0


Your select must be so:

SELECT h.h_dia FROM hh h WHERE cast(h.h_dia as date) = '2018-06-21' GROUP BY h.h_dia;

When the field is date and time, if you put in the filter only the date it will understand that the time is 00:00:00 and will not return correctly, so as you want to filter only by date, you must convert the field to date only.

If you want to filter by date and time do it as follows:

SELECT h.h_dia FROM hh h WHERE h.h_dia = '2018-06-21 10:45:00' GROUP BY h.h_dia;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.