Hi,
I want to display Month and Year combination in dropdown list from current year to 1950.
Like, August 2022, July 2022 ................. January 1950. And if I select any month from this list it should return me that month's last day.
I am referencing below link :
how to display year in combo box from 1905 to current year | OutSystems
thanks
Hello Khris.
Instead check this post I did a couple of days ago and is a lot easier to read: https://www.outsystems.com/forums/discussion/81073/show-the-month-and-year-between-range-of-1990-till-current-year-in-drop-down/
To return the last day the easiest way is add a month to day one of the month and remove one day.
AddDays(AddMonths(YourDate,1),-1)
Hey thanks Nuno to reply.
I got the solution which I was trying since couple of days.
Can you pls explain me these lines?
Year SQL:
WITH x AS (SELECT n FROM (VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) v(n))
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) Column1FROM x ones, x tens, x hundreds, x thousands ORDER BY 1
very thanks
The code was adapted from other things so it is not optimized for any particular usage.
This can be read in tiny bits.
SELECT n FROM (VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9))
returns one column with rows 0,1,2,3,4.....
Then we have
FROM x ones, x tens, x hundreds, x thousands
that will join all those mini-tables. Because of the order, they will be generated in the order we expect to see. All the ones, then all the tens then all the hundreds, and finally all the thousands.
0,0,0,0
0,0,0,1
0,0,0,2
...
9,9,9,9
Now the fun part is that our 10000 rows will be ordered but the content is irrelevant. We will have the row_number (temporary variable) will have numbers between 1 and 10000 and we can use that as a number for the year.
oh I see. Interesting.... :-)
thanks again