You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

To Get The Last Day of Month & First Day of Month in SQR

4 replies [Last post]
Guest's picture
Guest

#include datemath.sqc

#include datemath.sqc

!*****************************************
move &dateval to $dateval
show $dateval

do Format-DateTime($dateval,$Res_Date,{DEFCMP},'','')
show 'Res_Date'$Res_Date

move $Res_Date to $Res_Date1
let $Res_Date1 = substr($Res_Date1,1,4) || '-' || substr($Res_Date1,5,2)|| '-' || substr($Res_Date1,7,2)
show 'Res_Date1'$Res_Date1

do dtu-month-begin($Res_Date1,$start_dt)
do dtu-month-end($Res_Date1,$end_dt)

let $end_dt = substr($end_dt,9,2)||'-'||substr($end_dt,6,2)||'-'||substr($end_dt,1,4)

show 'endate' $end_dt

!***************************************

!***************************************

Lepa's picture
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: To Get The Last Day of Month & First Day of Month in SQR

Hi there,
Thanks for sharing the sample code. For your information, site members can share sample code by adding them as pages to the avaibale books. You will have to register to be able to do that.

Thanks again!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

oddsnends's picture
User offline. Last seen 11 years 19 weeks ago. Offline
Joined: 03/28/2008
Posts: 16
Re: To Get The Last Day of Month & First Day of Month in SQR

Normally I just use a select from dual. But there are many ways to do it obviously.

begin-select
to_char(last_day(add_months(sysdate, -1)) +1,'MM/DD/YYYY') &first_DOM
to_char(last_day(sysdate),'MM/DD/YYYY') &last_DOM
from dual
end-select

Lepa's picture
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: To Get The Last Day of Month & First Day of Month in SQR

Agree with you oddsnends and actually there is this post added not long ago that does exactly that, cheers!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Guest's picture
Guest (not verified)
Re: To Get The Last Day of Month & First Day of Month in SQR

Hi,
I Thinks its performance issue hitting database everytime is not good wat i feel..
Just interms of SQR Related I posted this...

By the wat thanks for u r comments.....

Venkat
-------