Home > database >  Turn the SQL statement date is equal to the number doesn't work
Turn the SQL statement date is equal to the number doesn't work

Time:09-19

The select RETURNTIME, RETURNSTATION from B_LEASEINFOHIS
Where RETURNTIME & gt;=to_date (' 2014-05-01 ', '- DD YYYY - MM) and RETURNTIME & lt;=to_date (' 2014-05-03 ', '- DD YYYY - MM)
RETURNTIME are date fields, I put the string in the to - date to date compared with RETURNTIME, but why do I choose to only data of May 2nd day

CodePudding user response:

You this two days of data should be 5.1 and 5.2;

Did you check these, 5.1 data;

CodePudding user response:

PS: give you moved to the development zone, there is basically no one went to;

CodePudding user response:

The equal sign can certainly use
Must be data problem

CodePudding user response:

To_date (' 2014-05-01 ', '- DD YYYY - MM) date format your actual format is 2014-05-01 00:00:00
Statement is no problem, you can find the 2014-05-01 data, should be a repository was not conform to the requirements of the data

CodePudding user response:

The
Quote: refer to the original poster jdd519328384 response:

The select RETURNTIME, RETURNSTATION from B_LEASEINFOHIS
Where RETURNTIME & gt;=to_date (' 2014-05-01 ', '- DD YYYY - MM) and RETURNTIME & lt;=to_date (' 2014-05-03 ', '- DD YYYY - MM)
RETURNTIME are date fields, I put the string in the to - date to date compared with RETURNTIME, but why do I choose to only data of May 2nd day [/

You get how much data is expected

CodePudding user response:

In between,
Example:
 
To_date (to_char (RETURNTIME, 'mm - dd yyyy -'), '- dd yyyy - mm) between to_date (' 2014-05-01', '- dd yyyy - mm) and to_date (' 2014-05-03', '- dd yyyy - mm)

CodePudding user response:

To_date (' 2014-05-03 ', '- DD YYYY - MM) 2014-05-03 00:00:00

RETURNTIME & gt;=to_date (' 2014-05-01 ', '- DD YYYY - MM)
Data should be some 1

RETURNTIME & lt;=to_date (' 2014-05-03 ', '- DD YYYY - MM)
This condition, if you want to get 3 data and modified to
RETURNTIME & lt; To_date (' 2014-05-03 ', '- DD YYYY - MM) + 1

CodePudding user response:

The equality of the available,

CodePudding user response:

1. The first determine any data, 1
2. Determine the stored data to have time, if the storage time May 3 do not check basically
Written RETURNTIME & gt;=the date '2014-5-1' and RETURNTIME CodePudding user response:

Equal sign can be used in the database query have 2014-5-1 this record, that there should be no,
You can then will the and convert between to try

CodePudding user response:

SQL statement used to_date () function must be noticed when querying data:
To_date (' 2014-05-01 ', '- dd yyyy - mm) default is to take "2014-05-01 00:00:00", so if you want to find out on May 1, 2014 to May 3 data, the correct term is:
RETURNTIME & gt;=to_date (' 2014-05-01 ', '- dd yyyy - mm) and a & lt; To_date (' 2014-05-04 ', '- dd yyyy - mm)
Or RETURNTIME & gt;=to_date (' 2014-05-01 ', '- dd yyyy - mm) and a & lt; To_date (' 2014-05-03 ', '- dd yyyy - mm) + 1
Or RETURNTIME & gt;=to_date (' 2014-05-01 00:00:00 ', '- dd yyyy - mm hh24: mi: ss') and a & lt; 23:59:59=to_date (' 2014-05-03 ', '- dd yyyy - mm hh24: mi: ss')

CodePudding user response:

There is no data change so give it a try, it is estimated that 1
The select RETURNTIME, RETURNSTATION from B_LEASEINFOHIS
Where RETURNTIME & gt; To_date (' 2014-04-30 ', '- DD YYYY - MM) and RETURNTIME & lt; To_date (' 2014-05-04 ', '- DD YYYY - MM);
  • Related