Merin Joseph Posted May 3, 2023 Share Posted May 3, 2023 Link to comment Share on other sites More sharing options...
Solution David Beagan Posted May 3, 2023 Solution Share Posted May 3, 2023 Looks like you are wanting to get FUTURE_SHIP_DATE values that are earlier than the current date-time — as well as the FUTURE_SHIP_DATE values that are NULL. Assuming that FUTURE_SHIP_DATE is of data type HYYMDS(FUTURE_SHIP_DATE LE '&DATEHYYMDS' OR FUTURE_SHIP_DATE IS MISSING) Link to comment Share on other sites More sharing options...
Patrick Huebgen Posted May 3, 2023 Share Posted May 3, 2023 Slightly different version - sample based on wf_retail TABLE FILE retail_samples/wf_retailBY HIGHEST wf_retail.WF_RETAIL_TIME_SALES.TIME_DATEWHERE WF_RETAIL.WF_RETAIL_PRODUCT.PRODUCT_CATEGORY EQ 'Accessories'AND (wf_retail.WF_RETAIL_TIME_SALES.TIME_DATE LE DT_CURRENT_DATE() OR wf_retail.WF_RETAIL_TIME_SALES.TIME_DATE IS MISSING)ENDIf your field is data time - use DT_CURRENT_DATETIME() Link to comment Share on other sites More sharing options...
Mat Barnard Posted May 4, 2023 Share Posted May 4, 2023 Actually the original code won't return any null FUTURE_SHIP_DATEs.The COALESCE will resolve to GETDATE() when the FUTURE_SHIP_DATE is null so the result will be zero.I think the predicate should just return FUTURE_SHIP_DATEs in the past. Link to comment Share on other sites More sharing options...
David Beagan Posted May 4, 2023 Share Posted May 4, 2023 Seems like it would return FUTURE_SHIP_DATE values of NULL. Notice the >=0 at the end of the line:GETDATE() - COALESCE(tl.FUTURE_SHIP_DATE,GETDATE()) >= 0 Link to comment Share on other sites More sharing options...
Merin Joseph Posted May 4, 2023 Author Share Posted May 4, 2023 Why its LE ? its GE right ??? DEFINE--- TODAY/YYMD = &YYMD;WHERE FUTURE_SHIP_DATE GE TODAY OR FUTURE_SHIP_DATE IS MISSING; Link to comment Share on other sites More sharing options...
David Beagan Posted May 4, 2023 Share Posted May 4, 2023 The FUTURE_SHIP_DATE is subtracted from GETDATE() and selecting the ones that are greater or equal to 0. This happens for FUTURE_SHIP_DATE earlier than or equal to today. Link to comment Share on other sites More sharing options...
Mat Barnard Posted May 5, 2023 Share Posted May 5, 2023 You're right of course.This is why I shouldn't answer questions before my first coffee of the day. :-) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now