SOLVED

Determine if a date belongs in a certain month

%3CLINGO-SUB%20id%3D%22lingo-sub-2973970%22%20slang%3D%22en-US%22%3EDetermine%20if%20a%20date%20belongs%20in%20a%20certain%20month%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2973970%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20all.%20I%20am%20new%20to%20this%20so%20hoping%20I%20am%20in%20the%20right%20place.%20Unfortunately%20I%20have%20no%20examples%20to%20share%20as%20I%20can't%20even%20begin%20to%20build%20a%20formula%20for%20what%20I%20am%20trying%20to%20do.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20here%20goes.%20I%20am%20trying%20to%20build%20a%20formula%20that%20will%20determine%20if%20a%20specific%20date%20belongs%20in%20one%20budget%20month%20or%20another.%20For%20context%2C%20this%20is%20to%20build%20an%20excel%20sheet%20for%20a%20home%20budget.%20I%20get%20paid%20on%20the%2028th%20of%20every%20month%2C%20so%20my%20budget%20month%20runs%20from%20the%2028th%20of%20this%20month%2C%20to%20the%2027th%20of%20the%20following%20month%2C%20and%20is%20named%20as%20the%20following%20month.%20So%20when%20I%20get%20paid%20on%2028%20November%2C%20that%20will%20be%20the%20budget%20month%20for%20December.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20needs%20to%20happen%2C%20is%20when%20I%20set%20the%20date%20of%20a%20Income%2FExpense%2C%20the%20formula%20needs%20to%20work%20out%2C%20in%20which%20budget%20month%20it%20will%20be%20received%20%2F%20paid.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20an%20example.%3C%2FP%3E%3CP%3EI%20pay%20my%20Car%20Insurance%20on%20%3CSTRONG%3E27%20November%202021%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20get%20paid%20on%20%3CSTRONG%3E28%20November%202021%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3EI%20pay%20my%20rent%20on%20%3CSTRONG%3E29%20November%202021%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20need%20the%20formula%20to%20do%3A%3C%2FP%3E%3CUL%3E%3CLI%3EReport%20that%20the%20Car%20Insurance%20is%20paid%20in%20the%20budget%20month%20of%20November%202021%3CUL%3E%3CLI%3EBudget%20month%20%3CSTRONG%3E28%20October%20to%2027%20November%3C%2FSTRONG%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EReport%20that%20I%20get%20paid%20in%20the%20Budget%20month%20of%20December%202021%3CUL%3E%3CLI%3EBudget%20month%20%3CSTRONG%3E28%20November%20to%2027%20December%3C%2FSTRONG%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EReport%20I%20pay%20my%20rent%20in%20the%20budget%20month%20of%20December%202021%3CUL%3E%3CLI%3EBudget%20month%20%3CSTRONG%3E28%20November%20to%2027%20December%3C%2FSTRONG%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EHoping%20there%20is%20a%20way%20to%20do%20this.%20I%20can%20if%20need%20be%20use%20an%20XLSM%20file%2C%20with%20a%20Customer%20Function.%3C%2FP%3E%3CP%3EThe%20final%20result%20needs%20to%20be%20in%20the%20format%20of%20%22YYYY-MM%22%20(2021-11%20or%202021-12)%20This%20is%20for%20sorting%20and%20filtering%20purposes.%20I%20can%20probably%20do%20this%20with%20%3DTEXT((%3CU%3E%3CEM%3E%3CSTRONG%3EThe%20Formula%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FU%3E)%2C%20%22YYYY-MM%22)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20Thanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2973970%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2974144%22%20slang%3D%22en-US%22%3ERe%3A%20Determine%20if%20a%20date%20belongs%20in%20a%20certain%20month%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2974144%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1221142%22%20target%3D%22_blank%22%3E%40BigDaveB%3C%2FA%3E%26nbsp%3BGlad%20it%20worked%20out.%20By%20the%20way%2C%20I%20just%20added%20another%20formula%20to%20my%20original%20post.%20It's%20a%20little%20bit%20more%20fancy%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2974045%22%20slang%3D%22en-US%22%3ERe%3A%20Determine%20if%20a%20date%20belongs%20in%20a%20certain%20month%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2974045%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1221142%22%20target%3D%22_blank%22%3E%40BigDaveB%3C%2FA%3E%26nbsp%3BThat%20could%20be%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DIF(DAY(A2)%26gt%3B%3D28%2CEOMONTH(A2%2C1)%2CEOMONTH(A2%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ewhere%20the%20date%20to%20check%20is%20in%20A2.%3C%2FP%3E%3CP%3ECustom%20format%20the%20cell%20that%20holds%20this%20formula%20as%20yyyy-mm%3C%2FP%3E%3CP%3EExample%20attached.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello all. I am new to this so hoping I am in the right place. Unfortunately I have no examples to share as I can't even begin to build a formula for what I am trying to do.

 

So here goes. I am trying to build a formula that will determine if a specific date belongs in one budget month or another. For context, this is to build an excel sheet for a home budget. I get paid on the 28th of every month, so my budget month runs from the 28th of this month, to the 27th of the following month, and is named as the following month. So when I get paid on 28 November, that will be the budget month for December.

 

What needs to happen, is when I set the date of a Income/Expense, the formula needs to work out, in which budget month it will be received / paid.

 

As an example.

I pay my Car Insurance on 27 November 2021

I get paid on 28 November 2021.

I pay my rent on 29 November 2021

 

What I need the formula to do:

  • Report that the Car Insurance is paid in the budget month of November 2021
    • Budget month 28 October to 27 November
  • Report that I get paid in the Budget month of December 2021
    • Budget month 28 November to 27 December
  • Report I pay my rent in the budget month of December 2021
    • Budget month 28 November to 27 December

Hoping there is a way to do this. I can if need be use an XLSM file, with a Customer Function.

The final result needs to be in the format of "YYYY-MM" (2021-11 or 2021-12) This is for sorting and filtering purposes. I can probably do this with =TEXT((The Formula), "YYYY-MM")

 

Many Thanks

3 Replies
best response confirmed by BigDaveB (New Contributor)
Solution

@BigDaveB That could be:

 

=IF(DAY(A2)>=28,EOMONTH(A2,1),EOMONTH(A2,0))

 

where the date to check is in A2.

Custom format the cell that holds this formula as yyyy-mm

Example attached. 

 

Edit: This one will work also:

=EOMONTH(A2,QUOTIENT(DAY(A2),28))

@Riny_van_Eekelen 

Hi Riny,
Thanks so much for that. I wasn't even close to that and was trying to build nested If (OR) statements that were long and complicated. But your formula hit the nail on the head.
I made one small change to allow for sorting and filtering of the column to suit my needs

=TEXT(IF(DAY(A2)>=28,EOMONTH(A2,1),EOMONTH(A2,0)),"yyyy-mm")

Again, thank you so much for this.

Dave

@BigDaveB Glad it worked out. By the way, I just added another formula to my original post. It's a little bit more fancy