Index: /branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php
===================================================================
--- /branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php	(revision 6605)
+++ /branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php	(revision 6667)
@@ -551,4 +551,9 @@
 }
 
+function pwg_db_date_to_ts($date) 
+{
+  return 'UNIX_TIMESTAMP('.$date.')';
+}
+
 // my_error returns (or send to standard output) the message concerning the
 // error occured for the last mysql query.
Index: /branches/2.1/include/dblayer/functions_sqlite.inc.php
===================================================================
--- /branches/2.1/include/dblayer/functions_sqlite.inc.php	(revision 6605)
+++ /branches/2.1/include/dblayer/functions_sqlite.inc.php	(revision 6667)
@@ -562,4 +562,9 @@
 }
 
+function pwg_db_date_to_ts($date) 
+{
+  return 'UNIX_TIMESTAMP('.$date.')';
+}
+
 // my_error returns (or send to standard output) the message concerning the
 // error occured for the last mysql query.
Index: /branches/2.1/include/dblayer/functions_mysql.inc.php
===================================================================
--- /branches/2.1/include/dblayer/functions_mysql.inc.php	(revision 6605)
+++ /branches/2.1/include/dblayer/functions_mysql.inc.php	(revision 6667)
@@ -637,4 +637,9 @@
 }
 
+function pwg_db_date_to_ts($date) 
+{
+  return 'UNIX_TIMESTAMP('.$date.')';
+}
+
 // my_error returns (or send to standard output) the message concerning the
 // error occured for the last mysql query.
Index: /branches/2.1/include/dblayer/functions_pgsql.inc.php
===================================================================
--- /branches/2.1/include/dblayer/functions_pgsql.inc.php	(revision 6605)
+++ /branches/2.1/include/dblayer/functions_pgsql.inc.php	(revision 6667)
@@ -597,4 +597,9 @@
 }
 
+function pwg_db_date_to_ts($date) 
+{
+  return 'EXTRACT(EPOCH FROM '.$date.')';
+}
+
 // my_error returns (or send to standard output) the message concerning the
 // error occured for the last pgsql query.
Index: /branches/2.1/include/functions_session.inc.php
===================================================================
--- /branches/2.1/include/functions_session.inc.php	(revision 6364)
+++ /branches/2.1/include/functions_session.inc.php	(revision 6667)
@@ -176,5 +176,5 @@
 DELETE
   FROM '.SESSIONS_TABLE.'
-  WHERE UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(expiration) > '
+  WHERE '.pwg_db_date_to_ts('NOW()').' - '.pwg_db_date_to_ts('expiration').' > '
   .$conf['session_length'].'
 ;';
