Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
christyna1993 pe Simpatie
Femeie
25 ani
Bucuresti
cauta Barbat
30 - 44 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [EXCEL] LAMBDA Function to Generate First and Last Day of Months Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 18 ani
Postari: 2308
GENERATE FIRST AND/OR LAST DAYS OF THE GIVEN NUMBER OF MONTHS IN GIVEN YEAR

I wanted a function to spill me the first and last day of the 12 months in 2024 for example.

Lambda to add to Name Manager:

=LAMBDA(year;months;[first_day];[last_day];
   LET(
      y; year;
      m_checked; IF(OR(months<1; MOD(months; 1)<>0); INT(ABS(months)); months);
      m; SEQUENCE(m_checked);
      fd; DATE(y; m; 1);
      ld; EOMONTH(fd; 0);
      f; IFERROR(first_day; 0);
      l; IFERROR(last_day; 0);
      SWITCH(
         TRUE;
         AND(f=0; l=0); HSTACK(fd; ld);
         AND(f=1; l=0); fd;
         AND(f=0; l=1); ld;
         AND(f=1; l=1); HSTACK(fd; ld);
         HSTACK(fd; ld)
      )
   )
)


USAGE:

=MONTHDAYS(2024; 12)  same as  =MONTHDAYS(2024; 12; 1; 1)
=MONTHDAYS(2024; 12; 1)
=MONTHDAYS(2024; 12;  ; 1)

If months < 1 and/or months has decimals, it will return the positive integer number of that.
So =MONTHDAYS(2024; -2,4)  same as =MONTHDAYS(2024; 2)

If months > 12 it goes to the next year and displays dates, e.g.:
=MONTHDAYS(2024; 13)
displays:
01.01.2024    31.01.2024
01.02.2024    29.02.2024
01.03.2024    31.03.2024
01.04.2024    30.04.2024
01.05.2024    31.05.2024
01.06.2024    30.06.2024
01.07.2024    31.07.2024
01.08.2024    31.08.2024
01.09.2024    30.09.2024
01.10.2024    31.10.2024
01.11.2024    30.11.2024
01.12.2024    31.12.2024
01.01.2025    31.01.2025


Source: ChatGPT, except for the m_checked variable which I made to prevent errors.


_______________________________________


pus acum 8 zile
   
Pagini: 1  

Mergi la