Ambigiuous column name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dougancil
    Contributor
    • Apr 2010
    • 347

    #1

    Ambigiuous column name

    I'm attempting to do two things in a query, first convert a field to a more readable format and then doing a join so that I can data within a certain time frame. Here's the query that I have so far:

    Code:
    select moncalladd.opname, moncalladd.schedname, moncalladd.adddate, moncalladd.initials, dateadd(n,moncalladd.Timestamp, '12/31/1899')-([timestamp]/1000)/60/1440 +1 as date
    into temptable3
    from mdr.dbo.moncalladd inner join mdr.dbo.moncalldelete
    on moncalladd.schedname = moncalldelete.schedname
    what I'd like to do is to add one line to this

    where date >= (this value will be a variable that I'll be passing from a web page)

    Can someone please assist?

    Thank you
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    If the offended column is the one you are trying to add in the WHERE clause, just add an alias name on it.

    Happy Coding!!!


    ~~ CK

    Comment

    • dougancil
      Contributor
      • Apr 2010
      • 347

      #3
      Ck,

      I actually worked through that and now have a formatting issue. I'm trying to convert my dates in my query from this format:

      yyyy/mm/dd to dd/mm/yyyy

      Here is the query I have now:

      select moncalladd.opna me, moncalladd.sche dname, moncalladd.addd ate, moncalladd.init ials, dateadd(n,monca lladd.Timestamp , '12/31/1899')-(moncalladd.tim estamp/1000)/60/1440 +1 as oncalldate
      from mdr.dbo.moncall add inner join mdr.dbo.moncall delete
      on moncalladd.sche dname = moncalldelete.s chedname and moncalladd.time stamp= moncalldelete.t imestamp
      WHERE dateadd(n,monca lladd.Timestamp , '12/31/1899')-(moncalladd.tim estamp/1000)/60/1440+1 >= '2011-03-11'

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        For formatting, just do it on your front-end. If it is really necessary, here, read this.


        Happy Coding!!!

        ~~ CK

        Comment

        • dougancil
          Contributor
          • Apr 2010
          • 347

          #5
          I actually think that I'm going to just force users via regular expression to enter dates a specific way.

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            Yes :)

            As a rule of thumb, formatting is always better handled in the front-end. Although I am also guilty of doing that in the back-end only because some functions are readily available in sql-server and will take a lot of coding in the front-end :)

            Happy Coding!!!

            ~~ CK

            Comment

            Working...