 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Robbert de GROOT
Joined: 13 Dec 2000 Posts: 53
|
|
Testing date/hour file |
|
Every day of the week we receive a file on our network, transmitted from within another server in the network. Before importing the file into our database we have to test the date and hour of the file to be imported. The file MUST be AFTER 0700 pm (1900) on the previous day. EXCEPT the one we receive on Monday. In that case the file MUST be created AFTER 0700 pm (1900) on Friday. Question : Is there a function that can test if the date and hour is after a given date and hour. In my sample the date/hour of the file after today()-n at 1900 where n is the number of days. Here 1 or 3 Or do we have to write a probably horrible function for this. Hope my question is clear Robbert de GROOT
|
|
Thu Jul 25, 2002 4:40 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: Testing date/hour file |
|
You can use DateDiff to calculate number of day between any given date and today For example Today( today_date ) DateDiff( date1, today_date, diff ) You can also use TimeDiff and DateTimeDiff for comparing time and date/time values. To get a file time use FileTime statement. To compare that time against 19:00 use isGreater or isLess Example (add variable declarations as needed ) // get all dates and times Today( today_date ) DayNumber( today_date, day_num ) FileTime( " my file", file_time ) FileDate( " my file", file_date ) // check for Monday IsEqual( day_num, 2, monday ) If( monday, MONDAY_COMPARE, OTHER_COMPARE ) MONDAY_COMPARE: // monday date check DateDiff( file_date, today, date_diff ) NotEqual( date_diff, 3, too_old ) If( too_old, SKIP_PROCESSING, CHECK_TIME ) OTHER_COMPARE: // date check DateDiff( file_date, today, date_diff ) NotEqual( date_diff, 1, too_old ) If( too_old, SKIP_PROCESSING, CHECK_TIME ) CHECK_TIME: IsLess( file_time, 19:00, too_old ) If( too_old, SKIP_PROCESSING, USE_IT ) USE_IT: ... here you code what you want to do with the file Exit SKIP_PROCESSING: ... here you put what you want to do when the file is not good : Every day of the week we receive a file on our network, transmitted from : within another server in the network. : Before importing the file into our database we have to test the date and hour : of the file to be imported. The file MUST be AFTER 0700 pm (1900) on the : previous day. EXCEPT the one we receive on Monday. In that case the file : MUST be created AFTER 0700 pm (1900) on Friday. : Question : Is there a function that can test if the date and hour is after a : given date and hour. In my sample the date/hour of the file after : today()-n at 1900 where n is the number of days. Here 1 or 3 : Or do we have to write a probably horrible function for this. : Hope my question is clear : Robbert de GROOT
|
|
Thu Jul 25, 2002 9:21 am |
|
 |
Robbert de GROOT
Joined: 13 Dec 2000 Posts: 53
|
|
Re: Testing date/hour file |
|
: You can use DateDiff to calculate number of day between any given date and : today : For example : Today( today_date ) : DateDiff( date1, today_date, diff ) : You can also use TimeDiff and DateTimeDiff for comparing time and date/time : values. To get a file time use FileTime statement. To compare that time : against 19:00 use isGreater or isLess : Example (add variable declarations as needed ) : // get all dates and times : Today( today_date ) : DayNumber( today_date, day_num ) : FileTime( " my file", file_time ) : FileDate( " my file", file_date ) : // check for Monday : IsEqual( day_num, 2, monday ) : If( monday, MONDAY_COMPARE, OTHER_COMPARE ) : MONDAY_COMPARE: // monday date check : DateDiff( file_date, today, date_diff ) : NotEqual( date_diff, 3, too_old ) : If( too_old, SKIP_PROCESSING, CHECK_TIME ) : OTHER_COMPARE: // date check : DateDiff( file_date, today, date_diff ) : NotEqual( date_diff, 1, too_old ) : If( too_old, SKIP_PROCESSING, CHECK_TIME ) : CHECK_TIME: IsLess( file_time, 19:00, too_old ) : If( too_old, SKIP_PROCESSING, USE_IT ) : USE_IT: ... here you code what you want to do with the file : Exit : SKIP_PROCESSING: ... here you put what you want to do when the file is not : good Thanks for the script. I analyzed what was done and observed this would not do exactly what I should like it to do. But anyway I'll use parts of your sample to write my script. I will do it in the following way : the date of the file to be tested has to be between today and today -n, where n is, in my exemple, 1 or 3. If this test is ok I then test if the time of the file is after 1900 only in the case the date of the file is equal to today -n. Anyway thanks for helping. I was just wondering if there was a standard JAL function that could all that in one time. Robbert
|
|
Fri Jul 26, 2002 9:08 am |
|
 |
Robbert de GROOT
Joined: 13 Dec 2000 Posts: 53
|
|
Re: Testing date/hour file |
|
: You can use DateDiff to calculate number of day between any given date and : today : For example : Today( today_date ) : DateDiff( date1, today_date, diff ) : You can also use TimeDiff and DateTimeDiff for comparing time and date/time : values. To get a file time use FileTime statement. To compare that time : against 19:00 use isGreater or isLess : Example (add variable declarations as needed ) : // get all dates and times : Today( today_date ) : DayNumber( today_date, day_num ) : FileTime( " my file", file_time ) : FileDate( " my file", file_date ) : // check for Monday : IsEqual( day_num, 2, monday ) : If( monday, MONDAY_COMPARE, OTHER_COMPARE ) : MONDAY_COMPARE: // monday date check : DateDiff( file_date, today, date_diff ) : NotEqual( date_diff, 3, too_old ) : If( too_old, SKIP_PROCESSING, CHECK_TIME ) : OTHER_COMPARE: // date check : DateDiff( file_date, today, date_diff ) : NotEqual( date_diff, 1, too_old ) : If( too_old, SKIP_PROCESSING, CHECK_TIME ) : CHECK_TIME: IsLess( file_time, 19:00, too_old ) : If( too_old, SKIP_PROCESSING, USE_IT ) : USE_IT: ... here you code what you want to do with the file : Exit : SKIP_PROCESSING: ... here you put what you want to do when the file is not : good I imagined the following script : Set (n,3) Today (date_right) DateAdd (date_right, -n, date_left) FileDate (FileNameDATA, file_date) FileTime (FileNameDATA, file_time) IsdateBetween (file_date, date_left, date_right, success) If( success, CHECK_TIME, SKIP_PROCESSING) CHECK_TIME: IsdateBetween (file_date, date_left, date_left, success) If( success, CHECK_TIME2, SKIP_PROCESSING) CHECK_TIME2: IsLess (file_time, "19:00:00", success If( success, SKIP_PROCESSING, USE_IT) SKIP_PROCESSING: ... here you put what you want to do when the file is not good Exit USE_IT: ... here you code what you want to do with the file Exit This seems to act I desired. Thanks again for helping and your scripting hints
|
|
Fri Jul 26, 2002 9:35 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: Testing date/hour file |
|
Please change in your script either DateAdd (date_right, -n, date_left) to DateAdd (date_right, -3, date_left) or use Set(n, -3) DateAdd (date_right, n, date_left) PS. "-n" is an expression, not a token. JAL doesn't unserstand nested expressions at this time. : I imagined the following script : Set (n,3) : Today (date_right) : DateAdd (date_right, -n, date_left) : FileDate (FileNameDATA, file_date) : FileTime (FileNameDATA, file_time) : IsdateBetween (file_date, date_left, date_right, success) : If( success, CHECK_TIME, SKIP_PROCESSING) : CHECK_TIME: IsdateBetween (file_date, date_left, date_left, success) : If( success, CHECK_TIME2, SKIP_PROCESSING) : CHECK_TIME2: IsLess (file_time, "19:00:00", success : If( success, SKIP_PROCESSING, USE_IT) : SKIP_PROCESSING: ... here you put what you want to do when the file is not : good : Exit : USE_IT: ... here you code what you want to do with the file : Exit : This seems to act I desired. : Thanks again for helping and your scripting hints
|
|
Fri Jul 26, 2002 11:12 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|