Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Administration & Installation

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
37%
Installation Wizard into new VRC
39%
Manual into existing VRC
3%
Manual into new VRC
21%
Total votes: 38

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 4th December 2017, 18:35
dromeo dromeo is offline
Junior Member
 
Join Date: Feb 2016
Posts: 11
dromeo is on a distinguished road
Baan: BAAN IV - DB: ORACLE - OS: WINDOWS 7
Smile Set Time (on UTC date) and get time()+chronometer.
Baan: ERP LN 6.1 FP10 (Infor ERP 10.4)
DB: Oracle 12cR1
OS: Linux - Other
C/S: Server

Hello,

I was searching in the forum, without any luck , a function to be used in a script, to get the time(), to be able to manage it, like a chronometer function, so to exit in case of a loop in a while iteration. For example:

--> get time(), after 10 seconds BREAK.

Other thing that I need to achieve: to add the time to an UTC field in a Program Script. It would be a specific time (8:00 a.m. for ex) to add to an UTC field (tdsls401.ddta, Planned Delivery Date). I'm getting the UTC date from that field, and on the script I subtract to that UTC date, a number of days based on a condition. The problem is that after I subtracted the number of days (I subtract the number on seconds) I need to add to the final date a SPECIFIC TIME.

Thank you very much!!!

Daniel Romeo
Reply With Quote
Sponsored Links
  #2  
Old 4th December 2017, 18:57
bdittmar's Avatar
bdittmar bdittmar is offline
Guru
 
Join Date: Apr 2002
Location: Germany, 50.584097,8.544078
Posts: 1,653
bdittmar will become famous soon enough
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox - DB: tbase, ms-sql7, oracle10gV1, 11g - OS: HP-UX, W2K3, SLES
utc.num() and sprintf()

Hello,

use utc.num() to get the current.
Then sprintf$() th format the time,
Code:
%U( format ) Use for UTC times.

This option enables you to define your own time using the following subformats of the ‘%U’ format.

%H hours in 24 hour format 
%h hours in 12 hour format 
%m minutes 
%s seconds 
%a substitutes the am/pm symbol as defined for the user language 
%x time separator as specified for the user language
Code:
utc.add()
Syntax:

function long utc.add  (long i.utc, long year, long month, long day, long hour, long minute, long second, long o.utc)

Description

This adds years, months, days, hours, minutes, seconds to the input utc value and makes corrections if necessary.

It processes the parameters from bigger to smaller units:

First adds only years and the date is corrected (if started from a leap year)
Than the months are added and the date is corrected to an existing one.
The addition of days follow, and the result is so far the same hour, minutes, as it was in the beginning in the actual time-zone.
Finally the hours, minutes, seconds are added.

Arguments

long i.utc  
long year  
long month  
long day  
long hour  
long minute  
long second  
long o.utc  
 
Return values

0 Success. 
1 Best guess. 
2 Failure. 
 
Context

This function can be used in all script types.

Example

This example shows the addition of days and hours across winter/summertime change

    in_utc = date.to.utc(2002,3,29,13,30,0)

    res = utc.add( in_utc, 0, 0, 1, 24, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017577800, res = 0 (that is 2002.3.31 14:30:00)

This example shows the addition of days across winter/summertime change

    in_utc = date.to.utc(2002,3,29,13,30,0)

    res = utc.add( in_utc, 0, 0, 2, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017574200, res = 0 (that is 2002.3.31 13:30:00)

This example shows the substraction of 1 month from March 31st, 2000.

        in_utc = date.to.utc(2000,3,31,9,0,0)

        res = utc.add( in_utc, 0, -1, 0, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=951811200, res = 1 (that is 2000.2.29 9:0:0)
__________________
//Bernd
Reply With Quote
  #3  
Old 4th December 2017, 22:37
dromeo dromeo is offline
Junior Member
 
Join Date: Feb 2016
Posts: 11
dromeo is on a distinguished road
Baan: BAAN IV - DB: ORACLE - OS: WINDOWS 7
Quote:
Originally Posted by bdittmar View Post
Hello,

use utc.num() to get the current.
Then sprintf$() th format the time,
Code:
%U( format ) Use for UTC times.

This option enables you to define your own time using the following subformats of the ‘%U’ format.

%H hours in 24 hour format 
%h hours in 12 hour format 
%m minutes 
%s seconds 
%a substitutes the am/pm symbol as defined for the user language 
%x time separator as specified for the user language
Code:
utc.add()
Syntax:

function long utc.add  (long i.utc, long year, long month, long day, long hour, long minute, long second, long o.utc)

Description

This adds years, months, days, hours, minutes, seconds to the input utc value and makes corrections if necessary.

It processes the parameters from bigger to smaller units:

First adds only years and the date is corrected (if started from a leap year)
Than the months are added and the date is corrected to an existing one.
The addition of days follow, and the result is so far the same hour, minutes, as it was in the beginning in the actual time-zone.
Finally the hours, minutes, seconds are added.

Arguments

long i.utc  
long year  
long month  
long day  
long hour  
long minute  
long second  
long o.utc  
 
Return values

0 Success. 
1 Best guess. 
2 Failure. 
 
Context

This function can be used in all script types.

Example

This example shows the addition of days and hours across winter/summertime change

    in_utc = date.to.utc(2002,3,29,13,30,0)

    res = utc.add( in_utc, 0, 0, 1, 24, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017577800, res = 0 (that is 2002.3.31 14:30:00)

This example shows the addition of days across winter/summertime change

    in_utc = date.to.utc(2002,3,29,13,30,0)

    res = utc.add( in_utc, 0, 0, 2, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=1017574200, res = 0 (that is 2002.3.31 13:30:00)

This example shows the substraction of 1 month from March 31st, 2000.

        in_utc = date.to.utc(2000,3,31,9,0,0)

        res = utc.add( in_utc, 0, -1, 0, 0, 0, 0, ou_utc )
The result in timezone "Europe/Amsterdam" is: ou_utc=951811200, res = 1 (that is 2000.2.29 9:0:0)
Hello bdittmar,

Thank you very much!! the function
Code:
utc.add()
worked well.. the only problem is that it's adding time (in the case I define the script like this)
Code:
res = utc.add( in_utc, 0, 0, 0, 8, 0, 0, ou_utc )
...and I need the time to be fix (8:00 a.m.) all the time, on all the cases when my condition is met....so for example if the user put on that field 4:00 p.m., once the script runs it will add 8 hours at the final time date, so the new time will be 12 a.m. and that's not good. It works fine when it's the inverse. The user has 12 a.m. on the planned delivery field and then the final time date it's 12+8 (8 a.m.) that is a good time since it's available on the calendar...the problem is that the original time will be always variable, that's why I need to put to my final date a fix time. Even if I rest or sum the time with that function is not good, because it will be always variable.

Thank you very much!!!

Daniel Romeo
Reply With Quote
  #4  
Old 5th December 2017, 17:55
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,322
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi,

What you need to do here is, take the mm,dd,yy,hh,mm,ss values out of your old date and store it in a new date using mm,dd,yy,8,0,0.

e.g

Code:
domain tcdate date.t
domain tcdate new.date
long dd,mm,yy,hh,mins,ss

date.t = utc.num() |# Could be 5-12-2018 20:01:02
utc.to.date(date.t,yy,mm,dd,hh,mins,ss)
new.date = date.to.utc((yy,mm, dd, 8,0,0)

I hope that is what you are looking for.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #5  
Old 6th December 2017, 18:57
dromeo dromeo is offline
Junior Member
 
Join Date: Feb 2016
Posts: 11
dromeo is on a distinguished road
Baan: BAAN IV - DB: ORACLE - OS: WINDOWS 7
Smile

Quote:
Originally Posted by bhushanchanda View Post
Hi,

What you need to do here is, take the mm,dd,yy,hh,mm,ss values out of your old date and store it in a new date using mm,dd,yy,8,0,0.

e.g

Code:
domain tcdate date.t
domain tcdate new.date
long dd,mm,yy,hh,mins,ss

date.t = utc.num() |# Could be 5-12-2018 20:01:02
utc.to.date(date.t,yy,mm,dd,hh,mins,ss)
new.date = date.to.utc((yy,mm, dd, 8,0,0)

I hope that is what you are looking for.
Hello bhushanchanda,

Thank you so much!!! It was exactly what I was looking for!!! Now I have the time fixed like I wanted and it worked perfectly!!! thank you so much again!!

just a little modification on my specific case, since I want to assign the fixed time to the field tdsls401.ddta, I'm sharing in case someone need it like this:

Code:
utc.to.date(tdsls401.ddta,yy,mm,dd,hh,mins,ss)
new.date = date.to.utc(yy,mm,dd,8,0,0)
tdsls401.ddta = new.date
Thank you again!!!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 01:14.


©2001-2017 - Baanboard.com - Baanforums.com