Results 1 to 2 of 2

Thread: Can query Assign on-or off-quarter based on date value?
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Oct 2019
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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?

  2. #2
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    16,492
    Post Thanks / Like
    Mentioned
    12 Post(s)
    Tagged
    1 Thread(s)

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

    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)
    	)

    Using: Office 2010/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •