Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7566033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:18:34+00:00 2026-05-30T14:18:34+00:00

I am a New ASP.NET Developer and I am trying to develop a simple

  • 0

I am a New ASP.NET Developer and I am trying to develop a simple suggestion box system. I have the following part of my database desing:

User Table: Username, Name, DivisionCode… etc

Division Table: SapCode, Division

SuggestionLog Table: ID, Title, Description, submittedDate, Username

(The first attribute is the primary key in each table and the attribute (submittedDate) is of DateTime data type)

Now, I need to develop a table that shows suggestions for the last three months. I already developed a query that shows the Employee Name, Username, Division, Suggestion Title, Suggestion Description. All what I want now is to show the Month. For example, to show the suggestions for the last three months, the Month column should show: Jan-2012, Dec-2011, Nov-2011 So how to do that?

My current SQL query:

SELECT     dbo.SafetySuggestionsLog.Title, dbo.SafetySuggestionsLog.Description, dbo.SafetySuggestionsType.Type, dbo.SafetySuggestionsLog.Username, 
                      dbo.employee.Name, dbo.Divisions.DivisionShortcut
FROM         dbo.Divisions INNER JOIN
                      dbo.employee ON dbo.Divisions.SapCode = dbo.employee.DivisionCode INNER JOIN
                      dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username INNER JOIN
                      dbo.SafetySuggestionsType ON dbo.SafetySuggestionsLog.TypeID = dbo.SafetySuggestionsType.ID

The desired output is to display:

Employee Name, Username, Division, SuggestionTitle, SuggstionDescription, SuggestionType Month(submissionDate)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:18:35+00:00Added an answer on May 30, 2026 at 2:18 pm

    I reformatted you query so it would fit on the page without scrolling.

    Hopefully this provides what you need. It uses DATENAME to get the month and year parts from the current date and DATEPART to do the “three months ago” calculation.
    Note that DATEPART doesn’t behave as you might expect – it counts the number of period-end boundaries (in this case months) – hence the condition is

    ...WHERE DATEDIFF(month,SafetySuggestionsLog.submittedDate,getdate()) < 3
    

    because the last three months have two month-end boundaries between them.

    I also added an ORDER BY clause.

    SELECT     dbo.SafetySuggestionsLog.Title, 
               dbo.SafetySuggestionsLog.Description, 
               dbo.SafetySuggestionsType.Type, 
               dbo.SafetySuggestionsLog.Username, 
               dbo.employee.Name, 
               dbo.Divisions.DivisionShortcut,
               left(datename(month,SafetySuggestionsLog.submittedDate),3) 
                + '-' 
                + datename(year,SafetySuggestionsLog.submittedDate) AS SubmittedMonth
    FROM         dbo.Divisions 
    INNER JOIN   dbo.employee 
    ON dbo.Divisions.SapCode = dbo.employee.DivisionCode 
    INNER JOIN   dbo.SafetySuggestionsLog 
    ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username 
    INNER JOIN   dbo.SafetySuggestionsType 
    ON dbo.SafetySuggestionsLog.TypeID = dbo.SafetySuggestionsType.ID
    WHERE DATEDIFF(month,SafetySuggestionsLog.submittedDate,getdate()) < 3
    ORDER BY SafetySuggestionsLog.submittedDate DESC
    

    It might also be worth noting that you don’t have to fully qualify the name of all the columns in the query – it’s valid SQL to alias the input tables like so:

    ...INNER JOIN   dbo.SafetySuggestionsLog AS log
    

    You can then refer to column names by alias in the query – e.g.

    log.Username
    

    instead of

    dbo.SafetySuggestionsLog.Username
    

    which makes it a bit easier to read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a brand new Java developer (I have been working in asp.net) and
I'm new to asp.net, mvc3 and entity framework. I'm trying to develop a mvc3
I am trying to develop an asp.net site with multiple subdomains. I am new
I'm a C# ASP.net MVC Developer. I got a new job and have to
I'm totally rewriting the question.. I'm new to ASP.Net, and trying to develop a
I am a new ASP.NET developer and I am trying to change the value
I'm new to ASP.NET (I'm a PHP developer) and I'm trying to understand how
I created a new ASP.NET website using Visual Web Developer 2008 Express edition and
I'm developer moving from C# to Java. Heard about new ASP net feature. <%:
I am going to develop a new website with asp.net 3.5 and LinqToSQL. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.