All Apps and Add-ons

DB connect postgres database SQL statement Unix timestamp filtering execution failed 02

Steven01
New Member

Hi, brother,

I have encountered a confusing problem regarding Postgres data integration.
I want to execute this statement every two minutes to retrieve the latest results from the database, so I use the following statement for filtering.

SELECT

history_uint.itemid,

history_uint.value,

interface.ip,

items.name,

hosts.host,

TO_TIMESTAMP(history_uint.clock) AS clock_datetime

FROM

history_uint

JOIN items ON history_uint.itemid = items.itemid

JOIN hosts ON items.hostid = hosts.hostid

JOIN interface ON interface.hostid = hosts.hostid

WHERE

history_uint.clock > (FLOOR(EXTRACT(EPOCH FROM NOW())) - 120)

AND items.flags = 4

AND (items.name LIKE '%Bits sent%' OR items.name LIKE '%Bits received%')

AND (hosts.host LIKE 'CN%' OR hosts.host LIKE 'os%')

ORDER BY

history_uint.clock DESC

LIMIT

90000;

 This SQL statement executes perfectly in database tools

Steven01_0-1730362278370.png

However, this SQL statement cannot be executed in dbxquery, and the error is unknown

Steven01_1-1730362351629.png

I found that the key reason is the following SQL statement:

Among them, history_uint.clock>(FLOOR (EXTRACT (EPOCH)
FROM NOW())) - 120)

When I replaced (FLOOR (EXTRACT (EPOCHFAM NOW()) -120) with Unix timestamps, everything was fine

Steven01_2-1730362426580.png

I tried to replace it with other SQL statements, but they all failed.
Please help me analyze this issue together. thank you.

Add some environmental information:
Postgres version: 14.9

Java version 21.0.5
DB connet version 3.18.1

Postgres JDBC version 1.2.1
thank you

Labels (1)
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...