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 8064941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:30:44+00:00 2026-06-05T11:30:44+00:00

I have the following SQL snippet: WHERE YEAR(wo.audt_created_dttm) >= 2011 – 3 –narrows down

  • 0

I have the following SQL snippet:

WHERE YEAR(wo.audt_created_dttm) >= 2011 - 3 --narrows down to a year
AND YEAR(wo.audt_created_dttm) >= 2006 -- bad data less than 2006
AND wo.audt_created_dttm < DATEADD(mm, 1, CAST(CAST(1 * 3 as varchar) + '/01/' +  CAST(2011 as varchar) as DateTime))

which I translated into LINQ to SQL (for testing purposes in LINQPad) like this:

int year = 2012, quarter = 1;
DateTime timeframe = new DateTime(year, (quarter * 3), 01).AddMonths(1); 


where wo.Audt_created_dttm.Value.Year >= year - 3 && wo.Audt_created_dttm.Value.Year >= 2006
    && wo.Audt_created_dttm < timeframe && (s.Id =="NM" || s.Id == "TH") && 
    (wo.Clsdt_date ?? new DateTime(3000, 01, 01)) < DateTime.Now

However, for the actual solution I do not want to specifically define the year or quarter. I want the year and quarter to be current.

For the year, I tried to do this:

DateTime timeframe = new DateTime(timeframe.Year, (quarter * 3), 01).AddMonths(1);

but the compiler doesn’t like that at all. Then I tried this:

DateTime setYear = new DateTime();
DateTime timeframe = new DateTime(setYear.Year, (quarter * 3), 01).AddMonths(1)

that didn’t work either. I’m at a loss for how to do either the year or the quarter and would appreciate any advice

  • 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-06-05T11:30:46+00:00Added an answer on June 5, 2026 at 11:30 am

    I want the year and quarter to be current.

    To get the first day of the current quarter you can use this code:

    var now = DateTime.Now;
    var quarter = (now.Month - 1)/3;
    var timeframe = new DateTime(now.Year, 3*quarter + 1, 1);
    

    timeframe will contain 2012-04-01, 2012-07-01, 2012-10-01 etc. depending on the current date.

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

Sidebar

Related Questions

I have the following SQL snippet within a select statement: CASE WHEN wot.id LIKE
I have the following SQL statement which has a very bad performance: SELECT frmInstLastModifiedDate
I have the following code snippet: PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i =
I have the PL/SQL code that is similar to the following snippet: create or
Consider the following snippet: Calendar futureDate = Calendar.getInstance(); int year = 2011; int month
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
I have following SQL query SELECT TOP 10000 AVG(DailyNodeAvailability.Availability) AS AVERAGE_of_Availability FROM Nodes INNER
Hi I have following sql statement that gives me the the first_name and total
I have the following SQL Server query: SELECT area FROM places WHERE REPLACE(area,'-',' ')
I have the following SQL query: SELECT r.BEZEICHNUNG AS BEZEICHNUNG, r.ID AS ID, ra.BEZEICHNUNG

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.