Results 1 to 4 of 4

Thread: update a field

  1. #1
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69

    Unanswered: update a field

    Hello,
    I have a field in a table that I have to update to the number of the week.
    Information i use is from another field, which is text in the format like :


    01022005
    02142005
    07082005
    11222005
    ...
    12022005

    mmddyyyy.

    How to write an update to update empty field with a number of the week based on the value from another field.



    Thank you very much.

  2. #2
    Join Date
    Jun 2005
    Posts
    45
    What do you mean by "number of the week"? Do you mean 1/1/2006 is in week #1 of the year, or do you mean 1/3/2006 is day #3 of the week?

    In either case, you should be able to use the DatePart function to get what you need.

    Hope this helps.
    Cathy

  3. #3
    Join Date
    Sep 2005
    Location
    Brooklyn, ny
    Posts
    69
    Yes, the 1/1/2006 is the week #1 and so on.

    but I need this for the year 2005 where the week number 1
    is from Dec 26, 2004 to Jan 1, 2005

    Thank you

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    SELECT DatePart(wk, Stuff(Stuff(d, 5, 0, '/'), 3, 0, '/'))
       FROM (SELECT '01022005' AS d UNION ALL
          SELECT    '02142005' UNION ALL
          SELECT    '07082005' UNION ALL
          SELECT    '11222005' UNION ALL
          SELECT    '12022005') AS z
    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •