Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8

    Unanswered: Join to feild not add them

    with my MSaccess back ground and leaning SQL fast

    I would like to join some feild together


    yy + mm + dd in SQL it will ad (Sum) them

    how do tell SQL to join

    so

    yy + mm + dd = yymmdd not the sum(yy+mm+dd)
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    CAST(mm AS VARCHAR)+CAST(dd AS VARCHAR)+CAST(yy AS VARCHAR)

    the next thing you're going to ask is how to stuff extra zeroes in there if one of the mm or dd or yy values is less than 10

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    Quote Originally Posted by r937
    CAST(mm AS VARCHAR)+CAST(dd AS VARCHAR)+CAST(yy AS VARCHAR)

    the next thing you're going to ask is how to stuff extra zeroes in there if one of the mm or dd or yy values is less than 10

    RIGHT (REPLICATE('0', 2) + CAST(MM AS VARCHAR), 2) somelike this r937
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  4. #4
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Nope, not myle, I'm faster .

    So here is the question: "How do I stuff extra zeroes in there if one of the mm or dd or yy values is less than 10?"

    Is it possible without the use of CASE WHEN mm < 10 then '0' END + CAST(mm AS VARCHAR) + ...
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  5. #5
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Dang my slow typing skills
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Heh
    Code:
    REPLICATE('0', 2)
    How come you have an aversion to
    Code:
    '00'
    ?


    And Wim - pwnd
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try this:

    RIGHT(yy+100,2)+RIGHT(mm+100,2)+RIGHT(dd+100,2)

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by r937
    RIGHT(yy+100,2)+RIGHT(mm+100,2)+RIGHT(dd+100,2)
    Srly?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you mean srsly, shurely

    and yes, that would be the solution for the problem as given in post #1, dude

    otherwise it woulda been RIGHT(yyyy+10000,4)

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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