Use Cron to modify posts via sql

Creating your own schedules is a little messy (because they need to be persistent and stored in database), but it is quite easy to hop on one of the native schedules that run twice a day.

add_action( 'wp_version_check', 'my_function' );

function my_function() {

    //stuff
}

As for running actual queries you should use $wpdb for that.