Baanboard.com

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

User login

Frontpage Sponsor

Main

Google search


Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
33%
Installation Wizard into new VRC
39%
Manual into existing VRC
6%
Manual into new VRC
22%
Total votes: 49

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 20th August 2007, 09:03
VishalMistry's Avatar
VishalMistry VishalMistry is offline
Guru
 
Join Date: Dec 2004
Location: India, Gujarat
Posts: 599
VishalMistry has a little shameless behaviour in the past
Baan: Baan IV, ERPLn - DB: SQL Server 2000 / 2008 - OS: Windows Server 2003 / 2008
Wink How to add specific no of months to a date field
Baan: Baan IVc4
C/S: Both

Hi all,

Can anyone help me on how i can add no.of.months/no.of.days to a specific date field.


Thanking in advance,
Vishal L. Mistry
Reply With Quote
  #2  
Old 20th August 2007, 10:31
en@frrom en@frrom is offline
Guru
 
Join Date: Aug 2003
Location: Belgium
Posts: 1,219
en@frrom will become famous soon enough
Baan: B50B - DB: Oracle 8.0 - OS: Win2k AS
I assume you mean how to programmatically add x months and/or x days to a given date...? Since your profile shows that you are on Baan IV, I also assume you mean regular date fields rather than utc fields?

Assuming the above, the following will work:

Let's say date contains a date entered by the user on the form, let's say it contains now 20/08/2007, And user inputs on form how many days and how many months he/she wants to add to selected date. User selected 6 months and 20 days.

extern domain tcmcs.long dys, mnths, numdate, retval, year, month, day

retval = num.to.date(numdate, year, month, day)
numdate = date.to.num(year + (month + mnths) / 12, (month + mnths) \ 12, day)
numdate = numdate + dys

numdate will now correctly contain 11/03/2008.

Hope this helps you and that it is clear to you. In case of any further questions, do not hesitate to ask.


Regards,
Eli Nager
__________________
Member of Baan Board

Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #3  
Old 21st August 2007, 10:19
VishalMistry's Avatar
VishalMistry VishalMistry is offline
Guru
 
Join Date: Dec 2004
Location: India, Gujarat
Posts: 599
VishalMistry has a little shameless behaviour in the past
Baan: Baan IV, ERPLn - DB: SQL Server 2000 / 2008 - OS: Windows Server 2003 / 2008
One more query

Hi,

Thanks for ur reply. Can u tell me if given a particular date, how i can separate year month and day and store them in separate variable.

Thanking u in advance,
Vishal
Reply With Quote
Sponsored Links
  #4  
Old 21st August 2007, 10:26
en@frrom en@frrom is offline
Guru
 
Join Date: Aug 2003
Location: Belgium
Posts: 1,219
en@frrom will become famous soon enough
Baan: B50B - DB: Oracle 8.0 - OS: Win2k AS
Vishal,

I see you don't quite understand the syntax of what I did in my example.

Quote:
Originally Posted by en@frrom View Post
retval = num.to.date(numdate, year, month, day)
This part takes the numeric date 'numdate' (number of days since 01/01/0001) and assigns the year,month and day values to the declared variables (of type long) year, month & date (could be any other name as well).

Regards,
Eli Nager
__________________
Member of Baan Board

Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #5  
Old 20th December 2010, 05:54
preethish preethish is offline
Member
 
Join Date: Oct 2010
Posts: 38
preethish is on a distinguished road
Baan: baan 4c4 and Lnfp2 - DB: sql - OS: windows2003
Quote:
Originally Posted by en@frrom View Post
I assume you mean how to programmatically add x months and/or x days to a given date...? Since your profile shows that you are on Baan IV, I also assume you mean regular date fields rather than utc fields?

Assuming the above, the following will work:

Let's say date contains a date entered by the user on the form, let's say it contains now 20/08/2007, And user inputs on form how many days and how many months he/she wants to add to selected date. User selected 6 months and 20 days.

extern domain tcmcs.long dys, mnths, numdate, retval, year, month, day

retval = num.to.date(numdate, year, month, day)
numdate = date.to.num(year + (month + mnths) / 12, (month + mnths) \ 12, day)
numdate = numdate + dys

numdate will now correctly contain 11/03/2008.

Hope this helps you and that it is clear to you. In case of any further questions, do not hesitate to ask.


Regards,
Eli Nager


Hi Eli nager,

Good ligic but there is a small bug if you are adding only 12 months to the date 20122010 then month feild will be zero (remainder is zero). it wont work out.

Regards,
Preeth
Reply With Quote
  #6  
Old 20th December 2010, 20:46
vinceco252's Avatar
vinceco252 vinceco252 is offline
Guru
 
Join Date: Mar 2002
Location: Frederick, CO
Posts: 409
vinceco252 is on a distinguished road
Baan: Baan IVc3, IVc4, 5b, 5c, ERP LN 6.1, Infor ERP 10.x - DB: SQL Server, Oracle - OS: Windows, Linux, HPUX, AIX, (a little bit of) Solaris
In LN, there is a utc.add function for adding dates...
__________________
Vincent Murphy
---------------
Senior ERP Consultant
OST
vmurphy@ostusa.com
Reply With Quote
  #7  
Old 16th March 2011, 11:24
Roeland Roeland is offline
Junior Member
 
Join Date: Dec 2006
Posts: 29
Roeland is on a distinguished road
Baan: IV SP28 - DB: SQL Server 2008 - OS: Windows 2008
The utc.add function is now also available in Baan IV:

retval = num.to.date(numdate, year, month, day)
in_utc = date.to.utc(year,month,day,0,0,0)
retval = utc.add(in_utc, 0, mnths, 0, 0, 0, 0, out_utc)
retval = utc.to.date(out_utc, year, month, day, dummy, dummy, dummy)
numdate = date.to.num(year, month, day)
Reply With Quote
  #8  
Old 25th April 2018, 16:56
v_kewl v_kewl is offline
Member
 
Join Date: Dec 2008
Posts: 58
v_kewl is on a distinguished road
Baan: LN 6.1 - DB: MS SQL - OS: Windows 2003
very old thread, but searching for the same, below code I have written for Baan IV

num.to.date(r.date, o.year, o.mnth, o.dayn)
o.mnth = o.mnth + month_to_be_added
if (o.mnth\12) = 0 then
o.year = o.year + ((o.mnth/12)-1)
o.mnth = 12
else
o.year = o.year + (o.mnth/12)
o.mnth = (o.mnth\12)
endif

r.date = date.to.num(o.year, o.mnth, o.dayn)
Reply With Quote
  #9  
Old 26th April 2018, 09:22
giggty's Avatar
giggty giggty is offline
Member
 
Join Date: May 2017
Posts: 62
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
v_kewl, why not use utc.add? Adding months like is error-prone.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Audit file structure baan_user Tools Development 8 4th May 2007 14:32
Add a new field jaybuffer88 Tools Development 5 4th April 2007 07:18
Initial value for a date field BaanForever Tools Development 2 12th November 2003 08:39
Date Field Error during Load Oracle Data into Microsoft SQL server through ODBC wangxn Tools Administration & Installation 2 11th April 2002 14:07


All times are GMT +2. The time now is 23:36.


©2001-2018 - Baanboard.com - Baanforums.com