Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2004
    Posts
    74

    Unanswered: Cleaning up hardcode sections

    Hey,

    Does anyone know of a neat and easy way to modify this section of hardcode:

    SELECT CASE dbo.requestsbyyeartemp.themonth when '1' then 'January' when '2' then 'Febuary' when '3' then 'March'
    when '4' then 'April' when '5' then 'May' when '6' then 'June' when '7' then 'July' when '8' then 'August'
    when '9' then 'September' when '10' then 'October' when '11' then 'November' when '12' then 'December' end as 'themonth', etc...

    Requestsbyyeartemp is a table where the numbers corresponding to the months are stored. This statement is used to make a new table where the months are stored with the proper names and not numbers.

    I would sooner not have any hardcode at all if there is a simple way to do it.

    Thanks

  2. #2
    Join Date
    Dec 2004
    Location
    CA, USA
    Posts
    63
    SELECT DATENAME(month, dbo.requestsbyyeartemp.themonth) AS 'themonth'

  3. #3
    Join Date
    Dec 2004
    Posts
    74
    Would this work if the <date> portion of DATENAME(<datepart>, <date>) is only a single number?

    I ask this because I keep getting January no matter what number 'themonth' is?
    Last edited by Spence23; 01-05-05 at 16:11.

  4. #4
    Join Date
    Dec 2004
    Posts
    74
    Any more suggestions anyone?

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    How about:
    Code:
    SELECT DateName(month, DateAdd(month
    ,  dbo.requestsbyyeartemp.themonth, '1950-12-01')) AS themonth
    -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
  •