|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Having ADD_MONTHS problems
I CANNOT get my sqlplus script to add months to a date field (date_tng_stat). Can someone please help. Here is the script:
select t.date_tng_stat, ADD_MONTHS(t.date_tng_stat,6) If I run the script without the ADD_MONTHS the date_tng_stat comes out in YYYYMMDD ex. 20060307. THat's how I want the end result of the ADD_MONTHS to be also. Hope this helps. Thanks. |
|
#2
|
||||
|
||||
|
It's just a formatting issue use a to_char to format the result of the add_months, like this:
Code:
SQL> select sysdate from dual; SYSDATE --------- 07-MAR-06 SQL> select to_char(sysdate, 'yyyymmdd') from dual; TO_CHAR( -------- 20060307 SQL> select to_char(add_months(sysdate, 6), 'yyyymmdd') from dual; TO_CHAR( -------- 20060907
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Having ADD_MONTHS problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|