Re: last day
Posted in 1996
> jparker@hpbs3645.boi.hp.com (Jack Parker) writes:
> LET out_date = (in_date - dn UNITS DAY + 1 UNITS DAY )
> + 1 UNITS MONTH - 1 UNITS DAY
This is nice. This also works in SQL using any part you need of this:
select anydate,
date((anydate - (day(anydate) - 1) units day)) as month_this_first,
date((anydate - (day(anydate) - 1) units day
+ 1 units month - 1 units day)) as month_this_last,
date((anydate - (day(anydate) - 1) units day
+ 1 units month)) as month_next_first,
date((anydate - (day(anydate) - 1) units day
+ 2 units month - 1 units day)) as month_next_last
from anytable
You need use the date function only to get returned values as dates.
Otherwise they will be returned as datetime.
Nils.Myklebust@ccmail.telemax.no
NM-data, Aasesvei 71, 1300 Sandvika, Norway
My opinions are those of my company