Unix Technical Forum

How to get the end value of month

This is a discussion on How to get the end value of month within the Informix forums, part of the Database Server Software category; --> Hi, I want to execute query for that i require end date of the month, suppose if the month ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 12:04 PM
Prateek Jain
 
Posts: n/a
Default How to get the end value of month

Hi,
I want to execute query for that i require end date of the month,

suppose if the month is April then it should return 30
if March then in should return 31
Is there any inbuilt function for that which give the end date of the month


Regards
Prateek.Jain

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 12:05 PM
Doug Lawry
 
Posts: n/a
Default Re: How to get the end value of month

"Prateek Jain" <prateekvjain@gmail.com> wrote in message
news:mailman.139.1147157764.848.informix-list@iiug.org...
> Hi,
> I want to execute query for that i require end date of the month,
>
> suppose if the month is April then it should return 30
> if March then in should return 31
> Is there any inbuilt function for that which give the end date of the month
>
> Regards
> Prateek.Jain


DATE( MDY(MONTH(TODAY),1,YEAR(TODAY)) + (1 UNITS MONTH) - (1 UNITS DAY) )

--
Regards,
Doug Lawry
www.douglawry.webhop.org



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 12:05 PM
Double Echo
 
Posts: n/a
Default Re: How to get the end value of month

Prateek Jain wrote:
> Hi,
> I want to execute query for that i require end date of the month,
>
> suppose if the month is April then it should return 30
> if March then in should return 31
> Is there any inbuilt function for that which give the end date of the month
>
>
> Regards
> Prateek.Jain


Build yourself a little case statement. Here's one in shell-script, you can
convert it easily enough into Informix-syntax. It also is a good way to get
the end-of-month without having to run a select statement, resulting in faster
performance without potential delay(s).

DAY=`date +%d`
MON=`date +%m`
YEAR=`date +%Y`
DOW=`date +%w`

IS_LEAP_YEAR=0
IS_LEAP_YEAR=`cal 2 $YEAR | grep 29`
case $MON in
01) EOM=31
;;

02)
if [ $IS_LEAP_YEAR ] ; then
EOM=29
else
EOM=28
fi
;;

03) EOM=31
;;

04) EOM=30
;;

05) EOM=31
;;

06) EOM=30
;;

07) EOM=31
;;

08) EOM=31
;;

09) EOM=30
;;

10) EOM=31
;;

11) EOM=30
;;

12) EOM=31
;;

esac

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2008, 12:07 PM
Art S. Kagel
 
Posts: n/a
Default Re: How to get the end value of month

Prateek Jain wrote:
> Hi,
> I want to execute query for that i require end date of the month,
>
> suppose if the month is April then it should return 30
> if March then in should return 31
> Is there any inbuilt function for that which give the end date of the month


Download June Hunt's presentation at the IIUG/IDUG User Conference last week
on SQL from the IIUG Web site. She deals with several of these type of
queries and time calculations there.

You all should have been there!

Art S. Kagel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-20-2008, 12:07 PM
Art S. Kagel
 
Posts: n/a
Default Re: How to get the end value of month

Prateek Jain wrote:
> Hi,
> I want to execute query for that i require end date of the month,
>
> suppose if the month is April then it should return 30
> if March then in should return 31
> Is there any inbuilt function for that which give the end date of the month


Download June Hunt's presentation at the IIUG/IDUG User Conference last week
on SQL from the IIUG Web site. She deals with several of these type of
queries and time calculations there.

You all should have been there!

Art S. Kagel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:59 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com