Page 1 of 1

last day from date

Posted: Wed May 08, 2013 7:56 pm
by smohd1338
i get yyyymmdd format date , i need output as yyyymmdd(but dd has to be last day of month 'mm', is there a direct funtion to pull last day of any month,

For Example: Input filed = 20130814, then output should = 20130831

Posted: Wed May 08, 2013 8:24 pm
by smohd1338
i foud, looks like daysinmonth should work

Posted: Wed May 08, 2013 8:55 pm
by smohd1338
there is no daysinmonth function in 8.1? how shall i write vthe loic without going into if then else

Posted: Wed May 08, 2013 9:07 pm
by chulett
Well... you could always play the old game of setting the date to the first day of the next month and then subtracting one day from it. :wink:

You could also build yourself a "DaysInMonth" routine... only four possible answers after all with some pretty well-known rules for the only one that is a variable.

Posted: Thu May 09, 2013 11:18 am
by priyadarshikunal
May be you can start from here.

Posted: Thu May 09, 2013 4:45 pm
by ray.wurlod

Code: Select all

Field("31|28|31|30|31|30|31|31|30|31|30|31", "|", MonthFromDate(InLink.TheDate), 1) 
is a quick way (ignoring leap years) to get the day number of the last day of the month. You can then build the date from components. Use an If..Then..Else derivation for the list to set the last day of February to 29 if it is a leap year.