Home > database >  About according to the monthly check in oracle data problems
About according to the monthly check in oracle data problems

Time:10-02


I'd like to check in chronological data wrote two ways, I don't know why is not the same as the amount of data the results
Select * from ppm_checkdebitdetail where
Trunc (Cdd_PassTime)=to_date (' 2013-7 ', 'yyyy - MM);
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Select * from ppm_checkdebitdetail where

To_CHAR (trunc (Cdd_PassTime), 'yyyy - MM)=' 2013-07 '

CodePudding user response:

Of course not the same, the select * from ppm_checkdebitdetail where
Trunc (Cdd_PassTime)=to_date (' 2013-7 ', 'yyyy - MM); Your query is the 2013-07-01 data,


Select * from ppm_checkdebitdetail where

To_CHAR (trunc (Cdd_PassTime), 'yyyy - MM)=' 2013-07 'query data from 2013-07

CodePudding user response:

reference 1st floor POM_24 response:
of course, the select * from ppm_checkdebitdetail where
Trunc (Cdd_PassTime)=to_date (' 2013-7 ', 'yyyy - MM); Your query is the 2013-07-01 data,


Select * from ppm_checkdebitdetail where

To_CHAR (trunc (Cdd_PassTime), 'yyyy - MM)=' 2013-07 'query is data from 2013-07


 select trunc (sysdate), trunc (sysdate - 17) to_date (' 2017-01 ', 'yyyy - MM) from dual; 
run it this way, you can understand,

CodePudding user response:

Upstairs is

In addition this sentence trunc omit the
 
Select * from ppm_checkdebitdetail where

To_CHAR (trunc (Cdd_PassTime), 'yyyy - MM)=' 2013-07 '

CodePudding user response:

Trunc (sysdate), only one parameter, truncate to day,

Trunc (sydate, 'mm), can be truncated to the month,

CodePudding user response:

reference 4 floor wmxcn2000 response:
trunc (sysdate), only one parameter, truncate to day,

Trunc (sydate, 'mm), can be truncated to month,


I can't, I tried trunc (sysdate, 'mm)
The results
 
SQL> SELECT trunc (sysdate, "mm") FROM dual;

TRUNC (SYSDATE, 'MM)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2017/1/1

SQL>

CodePudding user response:

reference 5 floor u012557814 reply:
Quote: refer to 4th floor wmxcn2000 response:

Trunc (sysdate), only one parameter, truncate to day,

Trunc (sydate, 'mm), can be truncated to month,


I can't, I tried trunc (sysdate, 'mm)
The results
 
SQL> SELECT trunc (sysdate, "mm") FROM dual;

TRUNC (SYSDATE, 'MM)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2017/1/1

SQL>


January, have what problem, it is truncated to month is January 1

CodePudding user response:

reference 5 floor u012557814 reply:
Quote: refer to 4th floor wmxcn2000 response:

Trunc (sysdate), only one parameter, truncate to day,

Trunc (sydate, 'mm), can be truncated to month,


I can't, I tried trunc (sysdate, 'mm)
The results
 
SQL> SELECT trunc (sysdate, "mm") FROM dual;

TRUNC (SYSDATE, 'MM)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
2017/1/1

SQL>
truncation to month said that year on January 1, truncate to day said that month 1, note the data format are yyyy - mm - dd hh24: mi: ss, that is to say trunc (sysdate, 'mm) real time point is 2017/1/1 00:00:00
  • Related