Answer the question
In order to leave comments, you need to log in
How to subtract 12 hours from a date in sql?
Good day. There is a request to the current sales database. DBMS Firebird 2.1. The request is made through isql.
SELECT
C.CODE AS "Табельный",
C.NAME AS "Ф.И.О.",
T.TRANZDATE AS "Дата",
max(T.TRANZTIME) AS "Время",
T.INFOSTR AS "Карта",
sum(T.SUMM) AS "Сумма"
FROM
DOCUMENT D
LEFT JOIN TRANZT T ON D.ID = T.DOCUMENTID
JOIN CLIENT C ON T.INFO2 = C.CODE -- òàá íîìåð
WHERE
T.TRANZDATE = cast('now' as date) and
T.TRANZTIME >='20:00:00' AND T.TRANZTIME <='08:00:00' AND
D.STATE = 1 AND
D.ISFISCAL = 1 AND
T.TRANZTYPE = '36' and
T.INFO = '8'
GROUP BY
C.CODE,
C.NAME,
T.TRANZDATE,
T.INFOSTR
T.TRANZDATE = cast('now' as date) and
T.TRANZTIME >='08:00:00' AND T.TRANZTIME <='20:00:00' AND
T.TRANZDATE = cast('now' as date) and
T.TRANZTIME >='20:00:00' AND T.TRANZTIME <='08:00:00' AND
T.TRANZDATE = dateadd (hour, -12, current_timestamp) and
Answer the question
In order to leave comments, you need to log in
Example from documentation :
dateadd (-12 hour to current_time)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question