Oracle: how to add minutes to a timestamp?

In addition to being able to add a number of days to a date, you can use interval data types assuming you are on Oracle 9i or later, which can be somewhat easier to read, SQL> ed Wrote file afiedt.buf SELECT sysdate, sysdate + interval ’30’ minute FROM dual SQL> / SYSDATE SYSDATE+INTERVAL’30’ ——————– ——————– … Read more

MySQL Select last 7 days

The WHERE clause is misplaced, it has to follow the table references and JOIN operations. Something like this: FROM tartikel p1 JOIN tartikelpict p2 ON p1.kArtikel = p2.kArtikel AND p2.nNr = 1 WHERE p1.dErstellt >= DATE(NOW() – INTERVAL 7 DAY) ORDER BY p1.kArtikel DESC EDIT (three plus years later)    The above essentially answers the question … Read more

Number of days between two dates C++

This is one way. #include <iostream> #include <ctime> int main() { struct std::tm a = {0,0,0,24,5,104}; /* June 24, 2004 */ struct std::tm b = {0,0,0,5,6,104}; /* July 5, 2004 */ std::time_t x = std::mktime(&a); std::time_t y = std::mktime(&b); if ( x != (std::time_t)(-1) && y != (std::time_t)(-1) ) { double difference = std::difftime(y, x) … Read more

Calculate business days in Oracle SQL(no functions or procedure)

The solution, finally: SELECT OrderNumber, InstallDate, CompleteDate, (TRUNC(CompleteDate) – TRUNC(InstallDate) ) +1 – ((((TRUNC(CompleteDate,’D’))-(TRUNC(InstallDate,’D’)))/7)*2) – (CASE WHEN TO_CHAR(InstallDate,’DY’,’nls_date_language=english’)=’SUN’ THEN 1 ELSE 0 END) – (CASE WHEN TO_CHAR(CompleteDate,’DY’,’nls_date_language=english’)=’SAT’ THEN 1 ELSE 0 END) as BusinessDays FROM Orders ORDER BY OrderNumber; Thanks for all your responses !

How do I get a timestamp in JavaScript?

Timestamp in milliseconds To get the number of milliseconds since Unix epoch, call Date.now: Date.now() Alternatively, use the unary operator + to call Date.prototype.valueOf: + new Date() Alternatively, call valueOf directly: new Date().valueOf() To support IE8 and earlier (see compatibility table), create a shim for Date.now: if (!Date.now) { Date.now = function() { return new … Read more

Calculate working hours between 2 dates in PostgreSQL

According to your question working hours are: Mo–Fr, 08:00–15:00. Rounded results For just two given timestamps Operating on units of 1 hour. Fractions are ignored, therefore not precise but simple: SELECT count(*) AS work_hours FROM generate_series (timestamp ‘2013-06-24 13:30’ , timestamp ‘2013-06-24 15:29’ – interval ‘1h’ , interval ‘1h’) h WHERE EXTRACT(ISODOW FROM h) < … Read more