Get Last Date in Month In PowerBuilder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
//==================================================================== // Function: f_lastdate() //-------------------------------------------------------------------- // Description: Get Last Date in Month //-------------------------------------------------------------------- // Arguments: // value Date adt_input //-------------------------------------------------------------------- // Returns: date //-------------------------------------------------------------------- // Usaged: Date dLastDate = f_lastdate(today()) //==================================================================== Integer iMonth, iDate iMonth = Month(adt_input) Choose Case iMonth Case 1, 3, 5, 7, 8, 10, 12 iDate = 31 Case 4, 6, 9, 11 iDate = 30 Case 2 If IsDate( '29/' + String(iMonth) + '/' + String(Year(adt_input))) Then iDate = 29 Else iDate = 28 End If End Choose adt_input = Date( String(iDate) + '/' + String(iMonth) + '/' + String(Year(adt_input))) Return adt_input |
Good Luck!
Here’s another way to do it :
Date ldt_LastDay
ldt_LastDay = Date(Year(adt_Input), Month(adt_Input), 25)
ldt_LastDay = RelativeDate(ldt_LastDay, 10)
ldt_LastDay = Date(Year(ldt_LastDay), Month(ldt_LastDay), 1)
ldt_LastDay = RelativeDate(ldt_LastDay, -1)
Return ldt_LastDay
thanks you share !