Combine two int columns without adding their numeric values together

  • I am trying to get a numeric value for the day of the week and the week of the month.

    Example: Today is 12/20/2011... so we are in the 4th week of the month and today (Tuesday) is the 2nd day of the week. (I am setting the DATEFIRST 1 so Monday is the first day of the week)

    I want to get a value of: 42 <--The first number is the week number and the second is the day of week.

    I have the code that gets me the two values, but when I try to combine them (not add them together) it just takes 4 + 2 and gives me 6, but I really want 42.

    Code that I'm using now:

    SET DATEFIRST 1 SELECT DATEPART(DW,SYSDATETIME()) + cast(datename(week,getdate()) as int)- cast( datename(week,dateadd(dd,1-day(getdate()),getdate())) as int)+1

    Any help would be great. Thank you.

  • CAST it again as CHAR/VARCHAR and concatenate.

  • That worked! Thanks for the help!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply