I have Oracle PLSQL code generating a list of date and time stamps, and I would like to truncate them at certain hours of 7 am and 7 pm, and not at the beginning of the day.
For example:
- 03/01/2013 0700 becomes 01/03/2013 0700
- 03/01/2013 1235 becomes 01/03/2013 0700
- 03/01/2013 1932 becomes 01/03/2013 1900
- 03/02/2013 0612 becomes 01/03/2013 1900
My code is currently:
SELECT TRUNC(TRUNC(SYSDATE,'hh') + 1/24 - (ROWNUM) / 24, 'dd') as shift_date FROM widsys.times ORDER BY SYSDATE
thanks
oracle plsql datetime truncate
user2793907
source share