Results 1 to 10 of 10
  1. #1
    Mordred is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Location
    Winnipeg, MB. Canada
    Posts
    8

    Show Year with Quarter

    Hi all,



    I have a problem that is also posted here regarding showing the year that corresponds to the quarter being queried. I use the following statement (is that the right terminology?) to call the quarterly data:
    Code:
    Quarters: IIf(Month([Datev]) In (1,2,3),"Q1",IIf(Month([Datev]) In (4,5,6),"Q2",IIf(Month([Datev]) In (7,8,9),"Q3","Q4"))),
    along with
    Code:
    Between #1/1/2007# And #12/1/2007#
    (not seen). How can I make the output of the query look like: Q1-07,Q2-07, and etc..? Any help is always appreciated!

    Regards:
    Last edited by Mordred; 06-30-2011 at 07:50 AM.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I'm not clear on what exactly you are doing/wanting to achieve, but

    format(Date,"YYYY-Q") where Date is today's date will give this output
    2011-2

  3. #3
    Mordred is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Location
    Winnipeg, MB. Canada
    Posts
    8
    Hi orange, thanks for the quick reply. I am relatively new to Access and thanks to my job I will be working with it a lot more. In saying that, I don't yet know where I would put "format(Date,"YYYY-Q"). I tried it in the properties window > Format, but that's not right because it does this: (d"ate,YYYY-Q)" after I run the code.

    Again, sorry to be daft about this but, I am!

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Perhaps you could try this in your query

    Qtr: format(Datev,"YYYY-Q")

    It may be useful, or at least something you can work with/from.

    Datev is a date field that you're interested in, correct?

  5. #5
    Mordred is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Location
    Winnipeg, MB. Canada
    Posts
    8
    Quote Originally Posted by orange View Post
    Perhaps you could try this in your query

    Qtr: format(Datev,"YYYY-Q")
    Where would I put that, in the field where I already have the statement from my first post? Or in the criteria? I tried the criteria with that and format(Date,"YYYY-Q") but the query outputted blank records.

    Quote Originally Posted by orange View Post
    Datev is a date field that you're interested in, correct?
    Yes, that is where all of my monthly data is.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try this

    Qtr: format(Datev,"YYYY-Q")

  7. #7
    Mordred is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Location
    Winnipeg, MB. Canada
    Posts
    8
    Thanks orange but that comes back with the months and the year. I am querying monthly data to make quarterly averages, that's why I have this:
    Code:
    Quarters: IIf(Month([Datev]) In (1,2,3),"Q1",IIf(Month([Datev]) In (4,5,6),"Q2",IIf(Month([Datev]) In (7,8,9),"Q3","Q4")))
    When I get rid of that for yours it queries only the months.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    This expression
    Qtr: format(Datev,"YYYY-Q")
    will return the 4 digit year and the quarter for a given date Datev.

    If Datev is Jun 29, 2011, then the expression will return 2011-2.

    If Datev is Aug 15, 2023, then the expression will return 2023-3.

  9. #9
    Mordred is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Location
    Winnipeg, MB. Canada
    Posts
    8
    Alright Orange, I see what you are saying. Thank you for that and the patience you have. Is there a way to make it display Q1-2011 instead of 2011-1?

  10. #10
    Mordred is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2011
    Location
    Winnipeg, MB. Canada
    Posts
    8
    Thank you so much Orange for guiding my way! I played with the expression and finally did:
    Qtr: "Q" & Format([Datev],"q-yyyy"). Now it displays exactly as I need it to. You rock!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. show records in this month last year?
    By geoffcox in forum Queries
    Replies: 4
    Last Post: 06-11-2011, 07:12 AM
  2. Replies: 2
    Last Post: 03-26-2011, 02:43 PM
  3. Service to Cost by Quarter HELP!!!
    By campanellisj in forum Database Design
    Replies: 5
    Last Post: 09-26-2010, 06:58 AM
  4. Replies: 23
    Last Post: 06-30-2010, 02:05 PM
  5. Sum bookings by quarter
    By kgav1 in forum Access
    Replies: 3
    Last Post: 04-14-2010, 08:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums