Query not sorting, but does on page refresh

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmorand
    New Member
    • Sep 2007
    • 219

    Query not sorting, but does on page refresh

    I have this query at the very top of my cfm file. It's right under the <body> tag. The date list which is returned from the query below isn't sorted in DESC order when the page first loads, but it does when you refresh the page. Why does this happen?

    I'm sorry for these questions, but I don't know where else to ask really.

    [code=cfm]
    <cfquery name="getEDV2_d t" datasource="Cod eGreyDW" dbtype="ODBC">

    SELECT tbledv2.date,tb ledv2.time from tbledv2
    UNION SELECT tbl3c.date,tbl3 c.time from tbl3C
    UNION SELECT tbl4.date,tbl4. time from tbl4
    UNION SELECT tblcodegreydiv. date,tblcodegre ydiv.time from tblcodegreydiv
    UNION SELECT tblfosterwing.d ate,tblfosterwi ng.time from tblfosterwing
    UNION SELECT tblicu.date,tbl icu.time from tblicu
    UNION SELECT tblmedsurg.date ,tblmedsurg.tim e from tblmedsurg
    ORDER by date DESC,time DESC

    </cfquery>

    <form method="post" action="BigPic_ dt_v2.cfm?refDT =123">
    </cfoutput>
    <SELECT name="ed_dt">
    <option>Selec t a Date/Time</option>
    <cfoutput query="getEDV2_ dt">
    <cfset ed_date=#DateFo rmat(date,"mm-dd-yy")#>
    <cfset ed_time=#TimeFo rmat(time,"HH:m m")#>
    <cfset DT=#ed_date# & ' ' & #ed_time#>
    <option>#DT#</option>
    <cfif isDefined("ed_d t")>
    <cfset #PDT# = #ed_dt#>
    </cfif>
    </cfoutput>
    </SELECT>
    <cfoutput>
    <cfif isDefined("ed_d t")>
    <input type="hidden" name="refreshDT " value="#ed_dt#" >
    </cfif>
    </cfoutput>
    <input type="submit" value="Refresh" >
    <cfif isDefined("ed_d t")>
    <cfset #CLIENT.ED_Date _Time# = #ed_dt#>
    </cfif>
    <cfoutput>PDT = #PDT#</cfoutput>
    </form>
    [/code]
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    It's probably your query which is the problem.

    I'd have to test, but try using the 'as' keyword to rename fields.

    Comment

    • dmorand
      New Member
      • Sep 2007
      • 219

      #3
      Originally posted by acoder
      It's probably your query which is the problem.

      I'd have to test, but try using the 'as' keyword to rename fields.
      Odd, but I just loaded the page up this morning, and it's sorting fine on the page load. My page is messing with me!!

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by dmorand
        Odd, but I just loaded the page up this morning, and it's sorting fine on the page load. My page is messing with me!!
        Don't you just hate it when that happens?

        Comment

        • dmorand
          New Member
          • Sep 2007
          • 219

          #5
          Originally posted by acoder
          Don't you just hate it when that happens?
          I really do because it was driving me crazy. I kept running the query in the Query Analyzer, and it worked fine no problems. Oh well, onto the next issue, haha.

          Comment

          Working...