I believe you need to add a month check for December using that method: IN.DATE='20040203'
NEW.YYYY = IN.DATE[1,4] NEW.MM = (IN.DATE[5,2]+1) 'R%2' IF NEW.MM=13 THEN NEW.MM='01' NEW.YYYY+=1 END I.LAST.DAY = ICONV(NEW.MM:"-01-":NEW.YYYY),"D4-")-1 -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Allen Egerton Sent: Thursday, June 02, 2005 10:57 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] Finding last day of month From: "Marco Manyevere" <[EMAIL PROTECTED]> > Hi, > > Given a date like 20040203, I want to return the last valid date for that month and year (20040229 in this case). What is the shortest code fragment to achieve this? Find the internal date of the first day of the next month, subtract 1, and convert it back to external format. ORIG.YYYY = YYYYMMDD[1,4] ORIG.MM = YYYYMMDD[5,2] ORIG.DD = YYYYMMDD[7,2] I.LAST.DAY = (ICONV(ORIG.YYYY:(ORIG.MM + 1): "01"), "D4/") - 1 O.LAST.DAY = OCONV(I.LAST.DAY, "D4/" ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/