SQL- date comparison

Results 1 to 4 of 4

Thread: SQL- date comparison

  1. #1
    Nils Guest

    Default SQL- date comparison

    I have a query on an Oracle table that gives me the results I want:<BR>strSQL = "Select jps_job.JOB_NUM, jps_job.INITIALS, jps_job.IDATE, jps_job.TITLE_NUM, jps_job_dates.LABLRECSDL, jps_title.LP_TECH_NAME "<BR> strSQL = strSQL & "from jps_job, jps_job_dates, jps_title "<BR> strSQL = strSQL & "where (jps_title.TITLE_NUM = jps_job.TITLE_NUM) and "<BR> strSQL = strSQL & "(jps_job.JOB_NUM = jps_job_dates.JOB_NUM) and "<BR> strSQL = strSQL & "(jps_job.JSTATUS &#060;&#062; &#039;50&#039;) and "<BR> strSQL = strSQL & "(jps_title.LP_TECH_NAME is not null) and "<BR> strSQL = strSQL & "(jps_job_dates.LABLRECSDL between to_date(&#039;"& varDate1 & "&#039;,&#039;mm/dd/yy&#039;) and to_date(&#039;" & varDate2 & "&#039;, &#039;mm/dd/yy&#039;)) "<BR> strSQL = strSQL & "order by jps_title.LP_TECH_NAME;"<BR><BR>In addition to the data this returns, I would also like to look at 2 other date fields (jps_job_dates.BINDSCHDL and jps_job_dates.BINDPLAN) and select the greater of the two. How do I do this?

  2. #2
    Tim Snyder Guest

    Default RE: SQL- date comparison

    SQL is not good at this....<BR>I suggest you get both dates and do a compare with the result displaying the one you want

  3. #3
    Join Date
    Dec 1969

    Default RE: SQL- date comparison

    You could put this in your select list<BR><BR>decode(sign(jps_job_dates.BINDSCHDL-jps_job_dates.BINDPLAN),<BR> -1,jps_job_dates.BINDPLAN,jps_job_dates.BINDSCHDL) as bigdate

  4. #4
    Nils Guest

    Default RE: SQL- date comparison

    That works! Thank you.

Posting Permissions

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