Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Using Between two Dates.

Using Between two Dates.

Scheduled Pinned Locked Moved Database
databasehelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    Hi, I have written a query to extract data from a table whose created date lies between current date and 30 days ago.in PL/SQL I have written query as follows: select creat_dt from shpt where shpt.creat_dt between trunc(sysdate) and trunc(sysdate-30) Although it is having records for which created date falls between current date and 30 days prior to current date, it still shows me no records extracted. Help me with this.

    A N 2 Replies Last reply
    0
    • R Rajiya

      Hi, I have written a query to extract data from a table whose created date lies between current date and 30 days ago.in PL/SQL I have written query as follows: select creat_dt from shpt where shpt.creat_dt between trunc(sysdate) and trunc(sysdate-30) Although it is having records for which created date falls between current date and 30 days prior to current date, it still shows me no records extracted. Help me with this.

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Don't know about Oracle, but in SQL Server that wouldn't work, you have to put the earliest date first.

      where shpt.creat_dt between trunc(sysdate-30) and trunc(sysdate)

      It's not logical, but thats how it works in SQL Server and I suspect Oracle!

      Bob Ashfield Consultants Ltd

      W 1 Reply Last reply
      0
      • A Ashfield

        Don't know about Oracle, but in SQL Server that wouldn't work, you have to put the earliest date first.

        where shpt.creat_dt between trunc(sysdate-30) and trunc(sysdate)

        It's not logical, but thats how it works in SQL Server and I suspect Oracle!

        Bob Ashfield Consultants Ltd

        W Offline
        W Offline
        Wendelius
        wrote on last edited by
        #3

        Yap, this applies to Oracle also. Based on ANSI standard between is converted to: Field >= StartValue AND Field <= EndValue Logical, isn't it :-D

        1 Reply Last reply
        0
        • R Rajiya

          Hi, I have written a query to extract data from a table whose created date lies between current date and 30 days ago.in PL/SQL I have written query as follows: select creat_dt from shpt where shpt.creat_dt between trunc(sysdate) and trunc(sysdate-30) Although it is having records for which created date falls between current date and 30 days prior to current date, it still shows me no records extracted. Help me with this.

          N Offline
          N Offline
          nelsonpaixao
          wrote on last edited by
          #4

          hi, try swap the dates between 20-10-2000 and 25-10-2001 between 25-10-2001 and 20-10-2000 it has to work no reason for otherwise:~

          nelsonpaixao@yahoo.com.br trying to help & get help

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups