Get only date without time in Oracle

I have this sql query to get some data, and I have this columd 'pa.fromdate' which returns the date and time. How can I get it to return only the date in the format "DD.MM.YYYY". I tried something like trunc(to_date(pa.fromdate, 'MM.DD.YYYY')). Does not work. How can i do this?

SELECT pro.inscatid,
  t.epotypeid,
  t.paysum,
  t.note,
  pa.blankno,
  pa.blankseria,
  pa.signtime,
  pa.fromdate,
  ca.accnum,
  ou.name,
  cst.inn,
  pkg_customers.GETCUSTOMERFULLNAME(cst.id) cstfio
FROM epo_orders t
LEFT JOIN epo_orderdetails od
ON od.orderid      = t.id
AND od.iscanceldoc = -1
LEFT JOIN plc_Agree pa
ON pa.id = od.agreeid
LEFT JOIN pro_products pro
ON pro.id = pa.proid
LEFT JOIN nsk_transferdetails td
ON td.transferid = pa.transferid
AND td.orgtypeid = 4
LEFT JOIN cst_customers cst
ON cst.id = t.cstid
LEFT JOIN cst_cstaccounts ca
ON ca.id = t.cstaccid
LEFT JOIN nsk_orgunits ou
ON td.orgunitid    = ou.id
WHERE t.epotypeid IN (159,1010,169,175)
AND rownum         <20;
+4
source share
5 answers

You can usually just truncate datetime with TRUNC:

TRUNC(pa.fromdate)

This removes the time portion from the date and time, so you only get the date. Then at your application level you will be interested in displaying it.

, . (, Windows), , . , , , .

(, ), TO_CHAR:

TO_CHAR(pa.fromdate, 'dd.mm.yyyy')
+7

select pro.inscatid,
t.epotypeid,
t.paysum,
t.note,
pa.blankno,
pa.blankseria,
pa.signtime,
to_char(pa.fromdate,'MM.DD.YYYY')fromdate,
ca.accnum,
ou.name,
cst.inn,
pkg_customers.GETCUSTOMERFULLNAME(cst.id) cstfio 
 from
epo_orders t
left join epo_orderdetails od on od.orderid = t.id and od.iscanceldoc = -1
left join plc_Agree pa on pa.id = od.agreeid
left join pro_products pro on pro.id = pa.proid
left join nsk_transferdetails td on td.transferid = pa.transferid and td.orgtypeid = 4
left join cst_customers cst on cst.id = t.cstid
left join cst_cstaccounts ca on ca.id = t.cstaccid
left join nsk_orgunits ou on td.orgunitid = ou.id 
where t.epotypeid in (159,1010,169,175) and rownum<20
0

to_char(pa.fromdate, 'MM.DD.YYYY'),

0

to_date() , to_char() ,

    select 
    ......
        to_char(pa.fromdate,'MM.DD.YYYY') fromdate
    ......
from ....
where ....
0

You can use the function for this to_char(). And you can use trunc()to solve your problem.

0
source

Source: https://habr.com/ru/post/1677663/


All Articles