1st of month following 30 days...

 7 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Shane Jones
Veteran Member Send Private Message
Posts: 460
Veteran Member

I am trying to use processflow to create a date based on the associate's hire date....   Any suggestions on how I can calculate the first of the month following 30 days?

I tried adding 30 days to hire date but then It still needs to figure the first of the next month ...   Right now I can not get a month formula to even calculate the month format correctly?

HIRED = query_DATE_HIRED

pfHIRED = pfDate(HIRED,'mm/dd/yyyy')

plus30 = AddDay(pfHIRED, 30)

MONTH = getMonth(plus30)

I ALMOST HAD IT .... but now I am having problems because the month of shows as 5 instead of 05  ....   (2008515 and I need 20080515)   I just need to force a leading 0

 

ANY THOUGHTS....

 

 

Shane Jones
Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
** Teach others to fish...
Shane Jones
Veteran Member Send Private Message
Posts: 460
Veteran Member
I have a flow that is ALMOST working but it is UGLY......

HIRED = I am pulling the DME formatted Date_Hired
PFHIRED = Converting HIRED to a pfDate string
PLUS30 = Adding 30 days to the PFHIRED
MONTH = Pulling the Month number from PLUS30 (seems to pull a number that is one less than what I want ?)
DAY = Pulling the Date (Day) from PLUS30
YEAR = Pulling the Year from PLUS30

Using a Branch I look at the following:

Day = 1 then it is the first of the next month (Use PLUS30 date as it is converted to AGSDATE = yyyymmdd)
ELSE...
MONTH = 12 then it is December and the next first of a month is ( (YEAR+1)+"0101" )
ELSE...
MONTH <10 then I need to pad a 0 to the month ( YEAR + "0" + (MONTH+1) + "01" )
ELSE...
TRUE Convert for months 10 and 11 ( YEAR + (MONTH+1) + "01" )

Still looking for some ideas... there has to be an easier way to do this?
Shane Jones
Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
** Teach others to fish...
Shane Jones
Veteran Member Send Private Message
Posts: 460
Veteran Member
Feel like I am talking to myself....

Any thoughts on why getMonth() would pull a number that is one less than the month from the date being used? Seems strange?

Shane
Shane Jones
Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
** Teach others to fish...
John Henley
Send Private Message
Posts: 3351
Sometimes the best answers I get are when I talk to myself...
I will see if I can dig up some code for you that is cleaner, but I won't be able to do it until tomorrow....if you can't wait, let me know.
Thanks for using the LawsonGuru.com forums!
John
k-rock
Veteran Member Send Private Message
Posts: 142
Veteran Member
Here is what I get
Date Hired 4/17/08

HIRED = 4/17/08
pfHired = 04/17/2008
plus30 = 05/17/2008
MONTH = 5

If you are looking for "the first of the month after 30 days", then you need to add this after MONTH:

First = MONTH + 1
FirstMonth = format(First, "00") [this is Access programming, use appropriate code for your system]
FirstDate = FirstMonth & "/01/" & Year(plus30)


Shane Jones
Veteran Member Send Private Message
Posts: 460
Veteran Member
k-Rock...

Thanks for your response. I am adding one to the month when I convert the date - however my issue is that I am getting this:

HIRED = 4/17/08
pfHired = 04/17/2008
plus30 = 05/17/2008
MONTH = 4

I added two to the month but that seems strange and I am not sure if it will be consistent???

Thanks
Shane
Shane Jones
Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
** Teach others to fish...
John Henley
Send Private Message
Posts: 3351
Hi Shane, I wasn't able to find an exact function to fit your needs, however I can tell you this:
- Javascript .getMonth() function returns 0 to 11, not 1 to 12, so "4" means "fifth" month.
- I also have had to use a left-zero-padding code like this:
// the month is zero based and is one less then it actually is
nMonth = d.getMonth()+1
// if the month is less then 10 insert a zero in front of the number
if(nMonth<10)
{
sMonth = "0"+nMonth.toString();
}
else
{
sMonth = nMonth.toString();
Thanks for using the LawsonGuru.com forums!
John
Shane Jones
Veteran Member Send Private Message
Posts: 460
Veteran Member
Thanks...

Your code is much cleaner for padding the zero. I really thought it was strange that the method getMonth() was one less than I wanted - that makes a lot more sense now.

Thanks
Shane
Shane Jones
Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
** Teach others to fish...