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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:26:33+00:00 2026-05-25T03:26:33+00:00

for every row in TableA i have a date and a week number field.

  • 0

for every row in TableA i have a date and a week number field. The date field is already populated and i was hoping there would be a way to automatically fill the Week number field aswell instead of having to do it manually.

an example of the date is as follows:
20111007

hope you can help, cheers 🙂

  • 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-25T03:26:34+00:00Added an answer on May 25, 2026 at 3:26 am

    With this syntax you can retrieve the week for a date.

    SELECT datepart(week, '20111007'), datepart(iso_week, '20111007')
    

    iso_week only works from sqlserver 2008 though.

    You really should consider making the week field into a computed column. It will make your life so much easier (I would use this solution).

    This would be your syntax:

    alter table <yourtable> add week1 as datepart(week, <yourdatecolumn>)
    

    Should you for some reason be prevented from making database changes, you could use this:

    UPDATE <table>
    SET <weekcolumn> = datepart(week, <yourdate>)
    WHERE week is null and <yourdate> is not null
    

    Problem is that if the date change, the week will still remain the same and the week will not be available until this script is used unless the week is updated with a trigger.

    You could also create a view to show all columns and add the week as a computed field, this would also be a valid solution. Although it is good practice to list the columns instead of using wildchar(*), I used it because i don’t know your columns.

    CREATE VIEW v_yourview as
    SELECT *, datepart(week, <yourdate>) week1 FROM <table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to avoid postbacks with gridview every time a row is
I have a table where every row has a unique id. The last table
I want to create an invoice of every 2 week. An invoice can have
I have a table with Serial(primary key), text, date It get's inserted every so
I want to apply right alignment on the last cell of every table row,
I am trying to set every row's CheckColor to Blue in the table tblCheckbook
while using beautifulsoup to parse a table in html every other row starts with
I'm writing a sparse matrix class in C++ in which every row and column
In MySQL, how can you select data where every row meets a certain condition?
Given a NxN matrix with 0s and 1s. Set every row that contains a

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.