5
I am trying to perform a query between two dates that returns the number of the week and counts progressively the week.
As an example :
Stayed like this :
SELECT ROUND((DATEDIFF(max(atendido_em_data),min(atendido_em_data)))/7) as semana,min(atendido_em_data) as min,max(atendido_em_data) as max
from ger_posicao;
I don’t understand why the bank keeps returning me like this:
Hello Cleber My table is set as date and the format is so 2018-04-30
– Carlos Lopes
Do so:
SELECT FLOOR(DATEDIFF(nome_do_campo_com_maior_data, DATE(nome_do_campo_com_menor_data))/7);
– Roberto de Campos
Adjusting as Roberto passed me, I have the minimum date 2018-04-30 and the maximum date 2018-05-10, the calculation returns me 1 and the correct would be 3 equal to the print I posted.
– Carlos Lopes
Carlos, I changed my example. In case they don’t reach 3 weeks (the result will be 2.85). You can use a ROUND() to get 3 in this case.
– Cleber Griff
I updated with the result adapted but unsuccessful yet.
– Carlos Lopes
@Carloslopes, take a look again of used this my example.. I tried here and it was without problems, I got Result "3".
– Cleber Griff