Results 1 to 2 of 2

Thread: Ordering

  1. #1
    Fion Guest

    Default Ordering

    I wish to retrieve records and display them ordered by "purchaseDate" a Date/Time data type in Access table. But my statement does not seem to work. <BR><BR>Please take a look and advise:<BR><BR>function GetPurchase<BR>dim sql,rs<BR>set rs = Server.CreateObject("ADODB.RecordSet")<BR> <BR>sql = "Select o_id as ""Purchase id"",purchaseDate as ""Date Initiated"", p_title as ""Project title"",totalAmt as ""Total Amount"", status as ""Current Status"" from purchase where staff_id = &#039"+user+"&#039 order by purchaseDate"<BR>rs.open sql,dbConn<BR>set GetPurchase = rs<BR>end function<BR><BR>Thanks.<BR>

  2. #2
    Britton Guest

    Default RE: Ordering

    I&#039ve cleaned up your statment a little, if your variable &#039user&#039 is a number, remove the single quotes. Other than that I don&#039t see a reason why it&#039s not working... Try my code. Also, because you made an alias for purchaseDate, you might have to use it&#039s alias to call an ORDER BY command. I just have never tried it so I&#039m not sure.<BR><BR>sql = "SELECT o_id AS purschaseID, purchaseDate AS dateInitiated, p_title AS projectTitle, totalAmt AS totalAmount, status AS currentStatus FROM purchase WHERE staff_id = &#039" & user & "&#039 ORDER BY purchaseDate"<BR>

Posting Permissions

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