Jump to content
Sign in to follow this  
rgarbin

Manipulação com Datas(SYSDATE)

Recommended Posts

SELECT SYSDATE DATA_ATUAL,ADD_MONTHS(SYSDATE,-1) MENOS_UM_MES,ADD_MONTHS(SYSDATE,1) MAIS_UM_MES,LAST_DAY(SYSDATE) ULTIMO_DIA_MES,TRUNC(SYSDATE,'MONTH') PRIMEIRO_DIA_MES,MONTHS_BETWEEN(SYSDATE,'01-JAN-2001') QTD_MES,FLOOR(MONTHS_BETWEEN(SYSDATE,'01-JAN-2001')) ARREDONDA_ABAIXO,CEIL(MONTHS_BETWEEN(SYSDATE,'01-JAN-2001')) ARREDONDA_ACIMA,ABS(MONTHS_BETWEEN(SYSDATE,'01-JAN-2001')) VALOR_ABSOLUTO,ROUND((MONTHS_BETWEEN(SYSDATE,'01-JAN-2001')),2) ARREDONDA,TRUNC(SYSDATE,'year') PRIMEIRO_DIA_ANO,to_char(SYSDATE,'dd " DE " FMMONTH " DE " YYYY','nls_date_language=portuguese') DIAMES_EXTENSO,to_char(SYSDATE,'FMMONTH " DE " YYYY','nls_date_language=portuguese') MES_EXTENSO,TO_CHAR(SYSDATE,'HH24:MI') HORA_MINUTO,to_char(sysdate,'FMMonth','nls_date_language=portuguese') mes_corrente,to_date(lpad(to_char(1234),4,'0'),'hh24mi') dias_data,Floor(floor(months_between(SYSDATE,SYSDATE)) / 12) IDADE,decode(TO_NUMBER(TO_CHAR(SYSDATE,'D')),2,'segunda-feira',3,'terça-feira',4,'quarta-feira',5,'quinta-feira',6,'sexta-feira',7,'sabado',1,'domingo') dia_da_semanaFROM DUAL

Share this post


Link to post
Share on other sites

SELECT NEXT_DAY(SYSDATE,3) FROM DUAL // PRÓXIMO DIA 0-DOM, 7-SAB

 

SELECT TO_CHAR(SYSDATE,'Q') FROM DUAL // 'QUATER' TRIMESTRE DO ANO , ÚTIL PARA REL. GERENCIAIS

Share this post


Link to post
Share on other sites

para não utilizar o decode:

 

select to_char(sysdate, 'Day', 'nls_date_language=portuguese') dia_da_semana
  from dual;

Share this post


Link to post
Share on other sites

Bom dia,

tente Select to_date(to_char(sysdate,'dd')||'/01/2017','dd/mm/yyyy') from dual;

mais elaboradamente, o mês e ano poderiam vir de uma tabela ou uma variável...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.