Click here to Skip to main content
14,774,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm not that grate with SQL is there a way to replace the date of the Timestamps with current Date -2 and in the other expression Current Date - 8 days

The most important part is the Time need to be set exactly like in below I try _add_day but then I can't set the time

the goal is : I want to schedule this report to run it automatically at Monday for previous week Sunday to Saturday and I want to remove the element of static / Manual entry date


select * from E_EVNT_SMRY_ELM
where SAM>0
and "E_EVNT_SMRY_ELM"."MOD_DATE_TIME" BETWEEN {ts '2020-11-01 00:00:01'}
AND  {ts '2020-11-07 23:59:59'}



any help will be appreciated

What I have tried:

I try _add_day but then I can't set the time
Posted
Updated 25-Nov-20 3:36am

Try:
UPDATE E_EVNT_SMRY_ELM 
SET TimestampColumn = ADDDATE(d, -2, GETDATE()),
    OtherTimestampColumn = ADDDATE(d, -8, GETDATE())
WHERE ...
   
Try:
SELECT
    *
FROM
    E_EVNT_SMRY_ELM
WHERE
    SAM > 0
And
    MOD_DATE_TIME > _add_days({current_date}, -8)
And
    MOD_DATE_TIME < _add_days({current_date}, -1)
   
Comments
SebSCO 25-Nov-20 9:11am
   
same as above need to be able to set static time to HH24:MI:SS
Richard Deeming 25-Nov-20 10:24am
   
If you use less than / greater than operators, the time component doesn't matter. "Modified on or before 11:59 PM on Sunday" is equivalent to "modified before midnight on Monday".
SebSCO 25-Nov-20 10:25am
   
It's sorted Thank You

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900