Home > Archive > Visual Basic Crystal Reports > February 2007 > I need help to concatenate text!!
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
I need help to concatenate text!!
|
|
|
| Hi all!
I am trying to create a report which checks on employees' hire date .
Based on the current date I need to get a list of employees who have
worked for a year. This is done to find out which employees have
worked for a year so that they get a salary increase on the first day
of the month on which they joined. What I am trying to do is check the
hire date, trim only the month part and concatenate this to 01/xx/
current year. So if the employee has a hire date 12/02/2006 the
outcome would be 01/02/2007 meaning that this employee should get an
increase on that date. Can anyone suggest some code to perform this?
Any help would be greatly appreciated. Thanks for your time!
| |
| Iain Sharp 2007-02-12, 7:16 pm |
| On 12 Feb 2007 05:34:03 -0800, "B." <bqirici@gmail.com> wrote:
>Hi all!
>I am trying to create a report which checks on employees' hire date .
>Based on the current date I need to get a list of employees who have
>worked for a year. This is done to find out which employees have
>worked for a year so that they get a salary increase on the first day
>of the month on which they joined. What I am trying to do is check the
>hire date, trim only the month part and concatenate this to 01/xx/
>current year. So if the employee has a hire date 12/02/2006 the
>outcome would be 01/02/2007 meaning that this employee should get an
>increase on that date. Can anyone suggest some code to perform this?
>Any help would be greatly appreciated. Thanks for your time!
dateadd("d",1-datepart("d",currentdate()),DateAdd ("Yyyy",1
,currentdate() ))
Replace currentdate() with your hire date (twice note)..
In longhand this translates to "add a year to hire date" and "subtract
the day part of the month from the above (+1)"
Alternatively,
dateserial(datepart("yyyy",currentdate())+1,datepart("m",currentdate()),01)
Build a date from hiredate.year +1 , hiredate.month, hiredate.day.
Fewer nested brackets in this one, making it easier to read.
| |
|
| I am sorry, I think I mislead you with my explanation. Employees get
the increase every year,meaning that they might have been working for
a year,two,three or more and not neccessarily just for a year. That is
why I want to extract only the month from the hire date and
concatenate that with the 1/xx/ current year where xx is the extracted
month. I need to get prompted that these employee on the 1st of the
extracted month of the current year need to get an increase in
salary.I am sorry for the mix up.Thank you!
| |
|
| i have modified the text as follows and now everything works perfectly
as it should. Thanks a million for your help!
local NumberVar sdatediff := DateDiff ("yyyy",
{RFACC_TTX.DATE_1} ,CurrentDate);
dateadd("d",1-datepart("d",{RFACC_TTX.DATE_1}),DateAdd
("Yyyy",sdatediff
,{RFACC_TTX.DATE_1} ))
| |
|
| However I am getting an error for an employee that has been hired on
the 29th of February. Instead of being propmted that this employee
increase date is 1/02/2007, I am getting prompted that this employee
should have an increase on 31/1/2007 which is wrong. How do I overcome
this? Thanks
| |
| Iain Sharp 2007-02-14, 4:17 am |
| On 13 Feb 2007 05:35:36 -0800, "B." <bqirici@gmail.com> wrote:
>However I am getting an error for an employee that has been hired on
>the 29th of February. Instead of being propmted that this employee
>increase date is 1/02/2007, I am getting prompted that this employee
>should have an increase on 31/1/2007 which is wrong. How do I overcome
>this? Thanks
This one :-
dateserial(datepart("yyyy",currentdate())+1,datepart("m",}{hiredate}),01)
should fix that.
Iain
|
|
|
|
|