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

  • Home
  • SEARCH
  • 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 7889887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:12:45+00:00 2026-06-03T06:12:45+00:00

Hi I have a table tab1 which have 2 columns. The values would be

  • 0

Hi I have a table tab1 which have 2 columns. The values would be like below

SL_NO     CAL_DATE
807        2012-03-18
808        2012-03-19
....
1170       2013-03-16

I need to select from this table between the range of sl_no is 807 and 1170. Apart from this, i need to select 2 derived columns for a week_no_of_month and week_no_of_year.

week_no_of_month will be first 7 days fall in week 1, next 7 days in week 2 like 4 weeks in a period. Then again it has to initialise from week no 1 till it reaches 4 for every 7 days.

week_no_of_year will start from 1 and it will keep continue for every 7 days till it reaches 52.

Please help me in this.

  • 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-03T06:12:46+00:00Added an answer on June 3, 2026 at 6:12 am

    I’m not sure what exactly you need. This will answer your question, but I suspect that this is not a question that should have been asked:

    select datediff (day, 
                     convert(varchar(4), year(CAL_DATE)) + '0101', 
                     CAL_DATE) / 7 + 1 WeekOfYear,
           (day(CAL_DATE) - 1) / 7 + 1 WeekOfMonth
    

    You might take a look at week numbering provided by Sql Server.

    UPDATE:

    declare @startOfFiscalYear as datetime
    set @startOfFiscalYear = '20120318'
    
    select datediff (day, 
                     @startOfFiscalYear, 
                     CAL_DATE) / 7 + 1 WeekOfYear,
           ((datediff (day, @startOfFiscalYear, CAL_DATE)) / 7 % 4) + 1 WeekOfMonth
    

    WeekOfYear is simply day of year divided by seven. WeekOfMonth is day of year divided by seven and then by four leaving modulus only.

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

Sidebar

Related Questions

I have Created a table like CREATE TABLE [dbo].[tab1]( [Id] [int] NOT NULL, [Name]
I have table with 3 columns A B C. I want to select *
I have table in data base name train delay, with columns train number(int), DelayTime(int),
I have the following problem. My table, say tab1, has name column as follows
I have table with 5 columns ------------------------------------------------------ |_id(mongo default)| link | name| street|zip |
i have 2 tables tab1 and tab2, tab2(tab1_id) references tab1(id) tab2 has different values
Suppose I have two table tab1, tab2. EF will create a edmx file and
I have a table which contains: -an ID for a financial instrument -the price
I would like to prepare session which will be using tables and in another
I have a table, 6 columns, the 6th column is empty but the other

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.