Can query Assign on-or off-quarter based on date value?

dls0406

New Member
Joined
Oct 7, 2019
Messages
15
I have a table which includes
Column 1: Client Name
Column 2: Project date (Must be last day of month)

The unique ID is a combination of column A and Column B. So, there may be multiple instances of the same client with different project dates.

I want to create a query that looks at the project dates and can tell me, by looking at the month, if the client has project dates that are on-quarter end (3/31, 6/30, 9/30 or 12/31) or not.

In an ideal world, I would have a query which lists all clients (1 row per client) and identifies them as either on-quarter or off-quarter.

Any suggestions for how to go about this?
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,626
Office Version
2013
Platform
Windows
I guess you will just put in your where criteria just as stated:

Code:
select * from Table1 where 
	(
	(datepart("m", [Project date]) = 3 and datepart("d", [Project date]) = 31)
	or 	
	(datepart("m", [Project date]) = 6 and datepart("d", [Project date]) = 30)
	or 	
	(datepart("m", [Project date]) = 9 and datepart("d", [Project date]) = 30)
	or 	
	(datepart("m", [Project date]) = 12 and datepart("d", [Project date]) = 31)
	)
equivalent with only two lines instead of four:
Code:
select * from Table1 where 
	(
	(datepart("m", [Project date]) in (3, 12) and datepart("d", [Project date]) = 31)
	or 	
	(datepart("m", [Project date]) in (6, 9) and datepart("d", [Project date]) = 30)
	)
 

Watch MrExcel Video

Forum statistics

Threads
1,095,168
Messages
5,442,796
Members
405,197
Latest member
queryashish

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top