- Posts: 54
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Concatenate two fields in equation field
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
7 years 4 days ago #151172
by nibos
Concatenate two fields in equation field was created by nibos
Hi there.
I am trying to include the following expression in a field's (equation type) description but doesn't work properly. I want this field to automatically get the value of another field (numeric or not) plus another text e.g. if(A5 == 'A1', A5 and 'text," ''). I want to have the value of a field (A5) followed by text (text). If I put only one of them works e.g. A5 or text but concatenated not.
What is the correct syntax?
Thank you.
I am trying to include the following expression in a field's (equation type) description but doesn't work properly. I want this field to automatically get the value of another field (numeric or not) plus another text e.g. if(A5 == 'A1', A5 and 'text," ''). I want to have the value of a field (A5) followed by text (text). If I put only one of them works e.g. A5 or text but concatenated not.
What is the correct syntax?
Thank you.
The topic has been locked.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5070
- Thank you received: 1263
7 years 4 days ago #151180
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Concatenate two fields in equation field
Perhaps this gives you an idea how to do it:
www.limesurvey.org/forum/design-issues/9...uation-type-question
www.limesurvey.org/forum/design-issues/9...uation-type-question
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
7 years 2 days ago #151313
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Concatenate two fields in equation field
Hi
A5.NAOK+'test' but better join(A5.NAOK,'test')
See manual.limesurvey.org/Expression_Manager#Operators
A5.NAOK+'test' but better join(A5.NAOK,'test')
See manual.limesurvey.org/Expression_Manager#Operators
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: gabriel01
The topic has been locked.
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 0
7 years 1 day ago #151356
by nibos
Replied by nibos on topic Concatenate two fields in equation field
Thank you for your reply. It worked with the following code ({if(A5=='A1','P' + DateFieldA,'')})but I have another issue.
One of the fields that I am using for the concatenation is date/time (DateFieldA) where I don't need/use the time and the format of the field is "dd-mm-yyyy". On the selection of the field the value is displayed correctly e.g. 27/03/2017 but when I use it to the other field as part of the concatenation the format that is being displayed on the result is as follows: "2017-03-09 00:00" How can it be displayed exactly as it is on the original field and with no time e.g. "dd-mm-yyyy"? Can I use format on the concatenation?
Thank you.
One of the fields that I am using for the concatenation is date/time (DateFieldA) where I don't need/use the time and the format of the field is "dd-mm-yyyy". On the selection of the field the value is displayed correctly e.g. 27/03/2017 but when I use it to the other field as part of the concatenation the format that is being displayed on the result is as follows: "2017-03-09 00:00" How can it be displayed exactly as it is on the original field and with no time e.g. "dd-mm-yyyy"? Can I use format on the concatenation?
Thank you.
The topic has been locked.
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 0
6 years 11 months ago #151805
by nibos
Replied by nibos on topic Concatenate two fields in equation field
Is it possible to use format in concatenation?
thank you.
thank you.
The topic has been locked.
- Deusdeorum
- Offline
- Senior Member
Less
More
- Posts: 72
- Thank you received: 17
6 years 11 months ago #151815
by Deusdeorum
Replied by Deusdeorum on topic Concatenate two fields in equation field
You can use the expression manager to remove hh:mm. I am sure there are several ways to do this but here's one way: {date("d/m/Y", stftotime(my_date_question))}
So in your case it would be something like: ({if(A5=='A1','P' + date("d/m/Y", strtotime(DateFieldA)),'')})
So in your case it would be something like: ({if(A5=='A1','P' + date("d/m/Y", strtotime(DateFieldA)),'')})
The following user(s) said Thank You: nibos
The topic has been locked.
- nibos
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 0
6 years 11 months ago #151817
by nibos
Replied by nibos on topic Concatenate two fields in equation field
Thank you very much, worked!
The topic has been locked.