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

Get current time in milliseconds using C++ and Boost

You can use boost::posix_time::time_duration to get the time range. E.g like this boost::posix_time::time_duration diff = tick – now; diff.total_milliseconds(); And to get a higher resolution you can change the clock you are using. For example to the boost::posix_time::microsec_clock, though this can be OS dependent. On Windows, for example, boost::posix_time::microsecond_clock has milisecond resolution, not microsecond. An … Read more

Update timestamp when row is updated in PostgreSQL

Create a function that updates the changetimestamp column of a table like so: CREATE OR REPLACE FUNCTION update_changetimestamp_column() RETURNS TRIGGER AS $$ BEGIN NEW.changetimestamp = now(); RETURN NEW; END; $$ language ‘plpgsql’; Create a trigger on the table that calls the update_changetimestamp_column() function whenever an update occurs like so: CREATE TRIGGER update_ab_changetimestamp BEFORE UPDATE ON … Read more