Good morning Ross,
If you have access to it, here is a link to my Alliance24 (Phoenix) presentation on DateTime and Query:
https://www.heug.org/communities/community-home/librarydocuments/viewdocument?DocumentKey=f0e4a3a2-4891-4498-b5d4-9019b68a146a
Also, I agree with Vic. You're doing it right already.
Find a date format that can be common to all of the fields you need.
Write each Date or Date/Time field as an expression, using SQL operators to manipulate the native format into the chosen common one.
Then, use those expressions in place of the native fields in your criteria, etc.
TRUNC may work in some circumstances. As will the operators I have listed in the table in my session.
Another you may try is SUBSTRING. Sometimes that is an efficient way to select the part of a DateTime field you need.
------------------------------
Scott Frey
Senior Data Analyst - Human Resource Information Systems
University of Colorado
------------------------------
Message from the HEUG Marketplace:------------------------------
Find, Review, and Engage with Higher Education-focused solution providers, products, and services using the
HEUG Marketplace.
------------------------------
Original Message:
Sent: 05-12-2025 05:59 PM
From: Ross Nolan
Subject: PS query and date fun
Does anyone have any suggestions on SQL tuning or getting around PS query messing with dates? In the past few months, I have been dealing with queries taking longer to run than they used to take. Many times, updating timestamp fields to date fields has fixed the issue, but I have to mess with changing the format of a field multiple times to do that. Below is an example snippet of a very ineloquent update. I am all ears on any suggestions when dealing with these issues, thanks!
Expression in PS query:
CASE
WHEN TO_DATE(B.POSTED_DATE,'YYYY-MM-DD') BETWEEN TO_DATE(J.SRVC_IND_DTTM,'YYYY-MM-DD') AND TO_DATE(J.AUDIT_STAMP,'YYYY-MM-DD') THEN...
The SQL tab on PS query:
CASE
WHEN TO_DATE( TO_CHAR(B.POSTED_DATE,'YYYY-MM-DD'),'YYYY-MM-DD') BETWEEN TO_DATE( TO_CHAR(CAST((J.SRVC_IND_DTTM) AS TIMESTAMP),'YYYY-MM-DD-HH24.MI.SS.FF'),'YYYY-MM-DD') AND TO_DATE( TO_CHAR(CAST((J.AUDIT_STAMP) AS TIMESTAMP),'YYYY-MM-DD-HH24.MI.SS.FF'),'YYYY-MM-DD') THEN
CS system details if helpful
PI Version: 9.2.033
Tools Version: 8.60.20
------------------------------
Ross Nolan
Data and Reporting Analysis
University of California, Berkeley
rvnolan@berkeley.edu
------------------------------