View Full Version: Add Days To A Date

LawsonTalk > BCI, Processflow and Addins > Add Days To A Date



Title: Add Days To A Date


vc727 - October 17, 2007 08:03 PM (GMT)
I am trying to develope a message to Managers whan a new employee is hired part of that message is telling them they need to have a 30 60 and 90 day review completed. I was hoping to tell them the exact days the reviews need to be completed by.

does anyone know the formats and java scripts that I would use to add days to a date. I have tried the AddDay that is in the developer but I t didn't work so I assume I have a format wrong or just don't know what it is supposed to do.

Any help would be appreciated.

ssun - October 17, 2007 10:37 PM (GMT)
Assuming dte1 is the date object of the your starting date, then 30 days later can be defined in javascript as

var dte30 = new Date(dte1.getTime() + 2592000000);

JavaScript stores dates in milliseconds.


shane pennington - October 18, 2007 02:19 PM (GMT)
I used the code below in a couple of similar flows in the past.

The code simply gives you the difference in days between two javascript formatted dates.

----------
/************************************************************
Function: SinceToday

Purpose: Calculates the difference in days between two
JavaScript dates (absolute value)
************************************************************/
function SinceToday(jsDate1,jsDate2)
{
var time1 = jsDate1.getTime();
var newDate1 = new Date(time1);
var time2 = jsDate2.getTime();
var newDate2 = new Date(time2);

//gdw - the DateDiff function ignores time
newDate1.setHours(0);
newDate1.setMinutes(0);
newDate1.setSeconds(0);
newDate1.setMilliseconds(0);
newDate2.setHours(0);
newDate2.setMinutes(0);
newDate2.setSeconds(0);
newDate2.setMilliseconds(0);

var x = newDate1.getTime();
var y = newDate2.getTime();
var temp = x - y;
//gdw - return the absolute value
if (temp < 0) temp = temp*(-1);
//gdw - there are 86400000 milliseconds in a day
var days = temp/86400000;
//days = '' + days;
return Math.floor(days);
}

------

GL,
~Shane

shane pennington - October 18, 2007 02:24 PM (GMT)
I just re-read your original post. I think all you're missing are calls to pfDate, and then getDateDME or getDateAGS. The AddDay function gives you a javascript formatted date. You probably just need to put that into a more easily readable format.

Try the following:

Pass your date variables to pfDate to change the AGS or DME dates from Lawson to javascript dates.

Call the AddDay function

Pass the return from AddDay to either getDateDME or getDateAGs.

GL, ;-)

vc727 - October 18, 2007 07:49 PM (GMT)
I can’t get the AddDate function to do anything.



I tried to convert the date with GetDate(jsDate) with my date variable in the jsDate and that gave me nothing







My initial field is date1 with a type of Date and it =today()



I assign that date to the effective date and it =10/14/2007



Then I try to do the date add and get nothing.



I am guessing mm/dd/yyyy isn’t a javascript date



Any thoughts


MannieJ - October 18, 2007 08:37 PM (GMT)
Try this.

String mydate=getDateAGS(AddDay(today(),+30))

just replace today() with what ever date object you have.

I use this to compare an oracle date format against a certain date in yyyymmdd format.

I believe Lawson changed the javascript date formatting from 802 to 803. We did have a lots of problem during conversion and I have to redo our date formatting just to compare against a database format. You will have to understand how your platform default date formats then choose the appropriate javascript date function. Always ask your server admin what type of date format the server uses.

Above is just one of the example in our processflows. I also use javascript date which is very long and just parse the first 10 character(parseint) to get todays date in yyyymmdd format.

MannieJ - October 18, 2007 08:58 PM (GMT)
Just a little clarification about date formatting and how each different platform(machine) will represent dates. We have different platforms from mainframe to windows, solaris, aix, tandem etc and some of them does not follow the ISO standard. We found this out the hard way when like our processflow was not working when we migrated from 802 to 803 and from solaris to aix. An example would be an oracle date is usually in yyyymmdd format, solaris will always represent this in mm/dd/yyyy format hence in 802 we use getdateDME but in 803 our aix machine has the same representation with oracle so we just use getdateAGS.

vc727 - October 19, 2007 02:41 PM (GMT)
I can't seem to get the date out of the mm/dd/yyyy format to do an AddDay function to it.

Ihave tried all of the different get date functions and it just ignores them altogether.

Here is the output of the query the effect date comes out in the mm/dd/yyyy format the other dates come out in yyyymmdd

I have dte1 in date format and when I assign it comes back as 10/14/2007 when I try and do anything with dte1 it just ignores it altogether.

I have tried
pfDate(dte1,'yyyymmdd')
getDateAGS(dte1)
getDate(dte1)


Codes_NEW_VALUE_36 =
Codes_NEW_VALUE_35 = M
Codes_NEW_VALUE_34 =
Codes_NEW_VALUE_33 = M
Codes_NEW_VALUE_32 = WH
Codes_NEW_VALUE_31 = 19660727
Codes_NEW_VALUE_30 = 520912
Codes_NEW_VALUE_29 = 000000061000000000+
Codes_NEW_VALUE_28 = 88880
Codes_NEW_VALUE_27 = 000000000200000000+
Codes_NEW_VALUE_26 = 037
Codes_NEW_VALUE_25 = 50%SPREAD
Codes_NEW_VALUE_24 = BW40
Codes_NEW_VALUE_23 = N
Codes_NEW_VALUE_22 = 000000000002000000+
Codes_NEW_VALUE_21 = H
Codes_NEW_VALUE_20 = 000000000001000000+
Codes_NEW_VALUE_19 = VCRMC1
Codes_NEW_VALUE_18 = 43-4161
Codes_NEW_VALUE_17 = 880
Codes_NEW_VALUE_16 = 0201
Codes_NEW_VALUE_15 = 316-456-7896
Codes_NEW_VALUE_14 = 67212
Codes_NEW_VALUE_13 = KS
Codes_NEW_VALUE_12 = WICHITA
Codes_NEW_VALUE_11 = 123456 SESAME STREET
Codes_NEW_VALUE_10 = 020188307200
Codes_NEW_VALUE_9 = 000000000016000000+
Codes_NEW_VALUE_8 = 000000000001000000+
Codes_NEW_VALUE_7 = A1
Codes_NEW_VALUE_6 = 010005973
Codes_NEW_VALUE_5 = 512554545
Codes_NEW_VALUE_4 =
Codes_NEW_VALUE_3 =
Codes_NEW_VALUE_2 =
Codes_NEW_VALUE_1 =
Codes_FLD_NBR_36 =
Codes_FLD_NBR_35 = 59
Codes_FLD_NBR_34 = 140
Codes_FLD_NBR_33 = 88
Codes_FLD_NBR_32 = 32
Codes_FLD_NBR_31 = 89
Codes_FLD_NBR_30 = 61
Codes_FLD_NBR_29 = 29
Codes_FLD_NBR_28 = 28
Codes_FLD_NBR_27 = 288
Codes_FLD_NBR_26 = 135
Codes_FLD_NBR_25 = 136
Codes_FLD_NBR_24 = 106
Codes_FLD_NBR_23 = 73
Codes_FLD_NBR_22 = 63
Codes_FLD_NBR_21 = 64
Codes_FLD_NBR_20 = 65
Codes_FLD_NBR_19 = 17
Codes_FLD_NBR_18 = 19
Codes_FLD_NBR_17 = 15
Codes_FLD_NBR_16 = 14
Codes_FLD_NBR_15 = 13
Codes_FLD_NBR_14 = 9
Codes_FLD_NBR_13 = 8
Codes_FLD_NBR_12 = 7
Codes_FLD_NBR_11 = 5
Codes_FLD_NBR_10 = 126
Codes_FLD_NBR_9 = 62
Codes_FLD_NBR_8 = 56
Codes_FLD_NBR_7 = 20
Codes_FLD_NBR_6 = 18
Codes_FLD_NBR_5 = 50
Codes_FLD_NBR_4 = 156
Codes_FLD_NBR_3 = 155
Codes_FLD_NBR_2 = 3
Codes_FLD_NBR_1 = 2
Codes_DEPARTMENT =
Codes_PROCESS_LEVEL =
Codes_ACTION_NBR = 1
Codes_ACTION_CODE = NEW HIRE
Codes_EFFECT_DATE = 10/14/2007
Codes_ACTION_TYPE = A
Codes_PARTICIPNT = 840874
Codes_COMPANY = 100
Codes_REASON_2 =
Codes_REASON_1 =


This is really getting frustraiting

MannieJ - October 19, 2007 02:59 PM (GMT)
Can you tell me your platform? aix, solaris etc
version? env apps
database?

I maybe able to help you.

vc727 - October 19, 2007 03:21 PM (GMT)
We are aix

8.0.3 tech

8.1 apps

Oracle database

MannieJ - October 19, 2007 03:38 PM (GMT)
Do you want to add days to today's date or a date in the database? Do you want to send the date in mm/dd/yyyy or something like "Oct 30, 2007" ?


vc727 - October 19, 2007 03:55 PM (GMT)
I need to add days to the effective date on the new hire action.

I am just the result in an email to tell the manager that they have to have a 30 day review completed by "date"

the mm/dd/yyyy format is ok for this purpose. the yyyymmdd is too confusing for end users to read.

If you can help that would be great.

MannieJ - October 19, 2007 04:19 PM (GMT)
try this. Let EFFDT = Effective Date in yyyymmdd (oracle).

1. Since EFFDT is in ags format, we will have to convert it to javascript date format.

1. In START - create variables Date jsdate=today(), String Days30=""
2. Covert EFFDT into javascript date: ASSIGN jsdate=pfDate(EFFDT,'yyyymmdd')
3. Add 30 days - ASSIGN Days30=getDateDME(AddDay(jsdate,+30))

.....Days30 will now have dates in mm/dd/yyyy format ..

Here's what is happening... in (803)... EFFDT is in ags format....convert to js date format because AddDay or AddMonth etc are in javascript format.. Also those getDateAGS and getDateDME were used to be intergers but now in string format.

Hope this helps.


vc727 - October 19, 2007 04:25 PM (GMT)
Ok the only question I have is about

QUOTE
try this. Let EFFDT = Effective Date in yyyymmdd (oracle).


The EFFDT is being sent to the process in mm/dd/yyyy format

Codes_EFFECT_DATE = 10/14/2007

Does this change what you are suggesting?

vc727 - October 19, 2007 04:32 PM (GMT)
I tried it as suggested and process flow ignores the assigns of both the jsDate and the Days30.

I can't help but think it has to do with the format of EFFDT when it starts the flow.

MannieJ - October 19, 2007 04:36 PM (GMT)
This tells me that your server uses mm/dd/yyyy as representation of a database dates. In this case it is always wise to do some trial and error. Use 'mm/dd/yyyy' or 'yyyymmdd' in pfDate function.

The purpose here is to covert an oracle date into a javascript date because the functions addDay, addMONTH and addYEAR are always in javascript format.

MannieJ - October 19, 2007 04:45 PM (GMT)
Can you also tell me what the table name of your EFFECT_DATE field?

MannieJ - October 19, 2007 05:07 PM (GMT)
I forgot to tell you that you have to create separate ASSIGN nodes for each functions you are calling. One for converting to js format, one for addinf days and one for converting into DME format. Do not put them in one ASSIGN node. So you will have something like:

ASSIGN1 -> ASSIGN2 -> Assign3 ->

If you are getting nothing (I usually email it to myself during testing), then it could be your database(could it be zeroes?).

vc727 - October 19, 2007 09:29 PM (GMT)
The field I am using is the PERSACTION.EFFECT_DATE field.


I have three assign nodes strung together but none of the fuctions is doing anything, when I look at the log in the designer. I have tried both date formats in pfDate mm/dd/yyyy and yyyymmdd and it ignores it all the other assignes in that node are there but not this date function.



MannieJ - October 19, 2007 10:44 PM (GMT)
can you use HIRED_DATE in EMPLOYEE table and see if you have result. We have the same platform and my testing are all oks. I will try to test the persaction table next.

Also check your pflow.js in your client pc vs the server($CCSDIR/lawson/processflow).

Your client pflow.js should be in Program File\Lawson Software\processflow. Check how the AGS and DME definitions like string, date or integer. Check versions too. I suspect you may have to reinstall your designer.

vc727 - October 22, 2007 12:37 PM (GMT)
Now that you say something about the pflow.js file. It makes me think, I am using a loaner laptop while mine is in the shop. On this one the pflow administrator scheduler and Event Management console will not run because of it cannot find \bin\javaw.

I will wait till I get my computer back to try this again. thanks for your help.





Hosted for free by InvisionFree