Finding the correct TIME

dabba23dabba23 Member Posts: 77
I have a process report that needs to consider the point of time it is run in order to set the correct filters.

I have written the following:


IF TIME >= 00:00:01 THEN
SETRANGE("Posting Date",CALCDATE('-1D',WORKDATE))
ELSE
SETRANGE("Posting Date",WORKDATE);

The point is that when the report is run after midnight, then it needs to filter on yesterdays posting date.
However, I have no idea how I find out if time is after midnight, as Time is of datatype Time and 00:00:01 is considered as an integer.

Any idea how I find after midnight?

Thanks
Ann

Comments

  • AlbertvhAlbertvh Member Posts: 516
    Hi Ann,

    use IF TIME > 000000T THEN :lol:
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Hardcoding ot time is

    000000T = 0:00:00

    101555T = 10:15:55

    Dates

    231206D = 23 12 2006
  • dabba23dabba23 Member Posts: 77
    Thanks for the help

    I have worked it out now :D
  • PellePelle Member Posts: 18
    Excuse my ignorance,
    but when is time NOT after midnight?

    //Pelle
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    :mrgreen:

    I'll bet she has a definition for that
  • Thomas_Hviid_ThornThomas_Hviid_Thorn Member Posts: 92
    Hej Ann,

    Whenever will the condition TIME > 000000T not be true ?

    Actually you must test not test on, whether you pass midnight, but whether the NowTime is less than you ProcessStartTime, i.e.:

    // Start of process
    ProcessStartTime := TIME;
    
    WHILE StillProcessing DO 
      BEGIN
        IF ProcessStartTime > TIME THEN
           use WORKDATE+1D
        ELSE
           use WORKDATE
        ... further processing
      END
    

    When again, this code only helps you partly: You will need to reconsider, if your process is delayed and started after midnight - nor if your process does continue over several days...
    With Kind Regards
    Thoms Hviid Thorn
Sign In or Register to comment.