Guys, beleza?
I need to do a SELECT where a date is between the period 1/01 (from any year) and 31/05 (from any year), I will return an indicator '1th semester'
and between 01/06 to 31/12 (from any year) = '2nd semester'.
How do I know if any date belongs to the first half?
- adrianoturbo
- Moderador
- Posts: 393
- Joined: Thu, 20 Mar 2008 4:09 pm
- Location: Brasília
Adriano Alves
---Para cada problema dificil existe uma solução simples.----
---Para cada problema dificil existe uma solução simples.----
Brother, converts the month in number with the function to_number, will actually need the function to_char as well to do the conversion into string and then in number, in the sequence place the filters and be happy, follow the codes of how to do.
select to_number(to_char(campo_data ,'mm') mês from qualquer_coisa
where mês <=6 --- primeiro semestre
select to_number(to_char(campo_data ,'mm') mês from qualquer_coisa
where mês >6 --- segundo semestre semestre
- Porva
- Rank: DBA Sênior
- Posts: 342
- Joined: Mon, 29 Jan 2007 7:36 am
- Location: São Paulo/SP
Rafael S. Nunes
São Paulo/SP
São Paulo/SP
Thanks Adriano,
The solution is even simple, I did not call, I also saw another function here in the forum that I found interesting, the function extract :
can use for days and years as well:
The solution is even simple, I did not call, I also saw another function here in the forum that I found interesting, the function extract :
SELECT EXTRACT(MONTH FROM SYSDATE) mês FROM dual;
can use for days and years as well:
SELECT EXTRACT(DAY FROM SYSDATE) mês FROM dual;
SELECT EXTRACT(YEAR FROM SYSDATE) mês FROM dual;
-
- Information
-
Who is online
Users browsing this forum: No registered users and 15 guests