Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Access Help

  • 24-02-2009 02:03PM
    #1
    Registered Users, Registered Users 2 Posts: 12,068 ✭✭✭✭


    I need help with Access queries and date functions.I'm required to do this and I would appreciate any help.

    The answer should display the startdate as a four digit year; as a numeric month and then a count of the projects.

    I think you use date part to get the year and month but the count doesn't work


Comments

  • Registered Users, Registered Users 2 Posts: 163 ✭✭stephenlane80


    Hi Titan,

    Post the table schema, and an sql version of the query so we can see whats going on,

    To get the query in sql view, right click it and go to sql view


  • Registered Users, Registered Users 2 Posts: 12,068 ✭✭✭✭titan18


    Hi Titan,

    Post the table schema, and an sql version of the query so we can see whats going on,

    To get the query in sql view, right click it and go to sql view

    SELECT tblProject.[Project Name], tblProject.[Start Date], tblProject.[End Date], tblProject.[Client Num], DatePart("yyyy",[Start Date]) AS [Year of Project], DatePart("m",[Start Date]) AS [Month of Project], Count(tblProject.[Start Date]) AS [Count of Projects in Month]
    FROM tblProject
    GROUP BY tblProject.[Project Name], tblProject.[Start Date], tblProject.[End Date], tblProject.[Client Num], DatePart("yyyy",[Start Date]), DatePart("m",[Start Date])
    HAVING (((tblProject.[Start Date])>#1/1/2007# And (tblProject.[Start Date])<#12/31/2008#))
    ORDER BY tblProject.[Start Date];



    Whats the table schema


  • Moderators Posts: 52,119 ✭✭✭✭Delirium


    titan18 wrote: »
    SELECT tblProject.[Project Name], tblProject.[Start Date], tblProject.[End Date], tblProject.[Client Num], DatePart("yyyy",[Start Date]) AS [Year of Project], DatePart("m",[Start Date]) AS [Month of Project], Count(tblProject.[Start Date]) AS [Count of Projects in Month]
    FROM tblProject
    GROUP BY tblProject.[Project Name], tblProject.[Start Date], tblProject.[End Date], tblProject.[Client Num], DatePart("yyyy",[Start Date]), DatePart("m",[Start Date])
    HAVING (((tblProject.[Start Date])>#1/1/2007# And (tblProject.[Start Date])<#12/31/2008#))
    ORDER BY tblProject.[Start Date];



    Whats the table schema

    You could try something like this.
    SELECT DatePart("yyyy",[Start Date]) AS [Year of Project], DatePart("m",[Start Date]) AS [Month of Project], Count(tblProject.[Start Date]) AS [Count of Projects in Month]
    FROM tblProject
    WHERE (((tblProject.[Start Date])>#1/1/2007# And (tblProject.[Start Date])<#12/31/2008#))
    GROUP BY DatePart("yyyy",[Start Date]), DatePart("m",[Start Date])
    ORDER BY DatePart("yyyy",[Start Date]) DatePart("m",[Start Date])  ;
    

    If you can read this, you're too close!



  • Registered Users, Registered Users 2 Posts: 12,068 ✭✭✭✭titan18


    koth wrote: »
    You could try something like this.
    SELECT DatePart("yyyy",[Start Date]) AS [Year of Project], DatePart("m",[Start Date]) AS [Month of Project], Count(tblProject.[Start Date]) AS [Count of Projects in Month]
    FROM tblProject
    WHERE (((tblProject.[Start Date])>#1/1/2007# And (tblProject.[Start Date])<#12/31/2008#))
    GROUP BY DatePart("yyyy",[Start Date]), DatePart("m",[Start Date])
    ORDER BY DatePart("yyyy",[Start Date]) DatePart("m",[Start Date])  ;
    


    thanks, that worked


  • Moderators Posts: 52,119 ✭✭✭✭Delirium


    titan18 wrote: »
    thanks, that worked
    No problem, glad it helped:)

    If you can read this, you're too close!



  • Advertisement
Advertisement