Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: how to get the next valid date?
How about this
select to_date(
to_char(col1,'mm')||'01'||to_char(col1,'yyyy'),
'mm/dd/yyyy')+
(to_char(col2,'dd')-1) from ...
Then in effect what you are doing is taking the 1st day of the mm/yyyy which
is always 1 and adding the number of days to the date and so the server will
automatically go to the right valid date.
Jim
"Prince Kumar" <gspk_at_yahoo.com> wrote in message
news:629275ba.0108311103.393c0bf4_at_posting.google.com...
> Hi,
>
> I have the following issue.
>
> I have to get the 'mm/yyyy' part of date from one column and 'dd' part
> from another column and cobine the both to for the result. When I do
> this, the result could be an invalid date. In such case, I need to get
> the next valid date.
>
> Ex.
> Col1 : 02/10/2000 -- mm/yyyy --> 02/2000 -- a
> Col2 : 10/31/2000 -- dd --> 31 -- b
>
> Res : a oper b --> 02/31/2000
>
> I want it to be either the previous or next valid date. In my case,
> result has to be either '02/29/2000' or '03/01/2000'. Anyone will do.
>
> Is this possible to do in SQL qry? If so, how?
>
> Thanks,
Received on Fri Aug 31 2001 - 15:29:07 CDT