1
I have the value 2016001
symbolizing the first day of the year 2016, how do I catch for example the ANO/MES
of 2016263
?
Example:
ENTRADA: $data = '2016001'
SAÍDA: $anomes = '2016-01'
If only I could do the opposite of that SQL
:
SELECT Extract(DOY FROM TIMESTAMP '2016-12-31 23:59:59') The day;
EXIT: 366
EDITED:
So I draw only the day number of the year:
SELECT SUBSTRING(TO_CHAR(2016263, '9999999') FROM 6 FOR 3)
EXIT: 263
Or the easy way:
SELECT RIGHT(2016263::VARCHAR, 3);
EXIT: 263
In my case he
2016263
is a whole, so I’ll modify your answer by putting aCAST
to get it right! Thanks for the collaboration!– Marcos Henzel
Blz @Marcoshenzel
– Camilo Santos
They did not let me improve your answer to be correct, they rejected the modifications, but alright, some data will be wrong there in the answer, referring to the data I passed in the question.
– Marcos Henzel
No problems, I edited the SQL command
– Camilo Santos