- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
add current month to var to re-use in multiple questions
- Luneya
- Topic Author
- Offline
- New Member
Less
More
10 years 3 weeks ago #106607
by Luneya
add current month to var to re-use in multiple questions was created by Luneya
Hello LimeSurvey-Super Heroes!
I have been searching the forum for an answer as I was sure I couldn't be the only with this particular question. However, I have not been able to find the answer.
I want to display the current month in the text of multiple questions.
Just the month. Nothing more, nothing less.
Furthermore I would like to be able to display the 3rd month prior to the current month (example, the current month is March so I would like to be able to display January.)
Is there no simple way like in php to display the current month?
Cheers,
Leonie
I have been searching the forum for an answer as I was sure I couldn't be the only with this particular question. However, I have not been able to find the answer.
I want to display the current month in the text of multiple questions.
Just the month. Nothing more, nothing less.
Furthermore I would like to be able to display the 3rd month prior to the current month (example, the current month is March so I would like to be able to display January.)
Is there no simple way like in php to display the current month?
Cheers,
Leonie
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
10 years 3 weeks ago - 10 years 3 weeks ago #106612
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic add current month to var to re-use in multiple questions
Expression manager -
manual.limesurvey.org/Expression_Manager
.
Current month:
Your example (March --> January) is actually the second previous month, not the third:
.
Current month:
Code:
{date('F')}
Your example (March --> January) is actually the second previous month, not the third:
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 3 weeks ago by tpartner.
The following user(s) said Thank You: Luneya
The topic has been locked.
- Luneya
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
10 years 3 weeks ago #106615
by Luneya
Replied by Luneya on topic add current month to var to re-use in multiple questions
Hi tpartner,
thank you for your reply. And you are indeed right, 3 months would make it December
The {date('F')} works! I figured it would relay it back to me in the language the survey is set to, but this does not seem to be the case. How do I get it to display the month in Dutch, rather than English?
We have version 2.00+ (build 130526) and it does not seem to recognize the strtotime part of the code. It is outlined in red and says the function is unknown when I hover over it.
Is this perhaps a feature from a newer build?
Thnx again for responding to my request!
thank you for your reply. And you are indeed right, 3 months would make it December
The {date('F')} works! I figured it would relay it back to me in the language the survey is set to, but this does not seem to be the case. How do I get it to display the month in Dutch, rather than English?
We have version 2.00+ (build 130526) and it does not seem to recognize the strtotime part of the code. It is outlined in red and says the function is unknown when I hover over it.
Is this perhaps a feature from a newer build?
Thnx again for responding to my request!
The topic has been locked.
- tpartner
- Away
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
10 years 3 weeks ago #106622
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic add current month to var to re-use in multiple questions
Ah, sorry, I assumed you are using 2.05.
It's a bit ugly but you can use nested IF() statements to handle the localization. Something like this (remove the line-breaks that I have added for clarity):
And something similar for the previous months:
It's a bit ugly but you can use nested IF() statements to handle the localization. Something like this (remove the line-breaks that I have added for clarity):
Code:
{if(date('F') == 'January', 'januari', if(date('F') == 'February', 'februari', if(date('F') == 'March', 'maart', if(date('F') == 'April', 'april', if(date('F') == 'May', 'mei', if(date('F') == 'June', 'juni', if(date('F') == 'July', 'juli', if(date('F') == 'August', 'augustus', if(date('F') == 'September', 'september', if(date('F') == 'October', 'oktober', if(date('F') == 'November', 'november', if(date('F') == 'December', 'december', ''))))))))))))}
And something similar for the previous months:
Code:
{if(date('F') == 'January', 'november', if(date('F') == 'February', 'december', if(date('F') == 'March', 'januari', if(date('F') == 'April', 'februari', if(date('F') == 'May', 'maart', if(date('F') == 'June', 'april', if(date('F') == 'July', 'mei', if(date('F') == 'August', 'juni', if(date('F') == 'September', 'juli', if(date('F') == 'October', 'augustus', if(date('F') == 'November', 'september', if(date('F') == 'December', 'oktober', ''))))))))))))}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Luneya
The topic has been locked.
- Luneya
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
10 years 3 weeks ago #106623
by Luneya
Replied by Luneya on topic add current month to var to re-use in multiple questions
Thank you so much!
I hope we will upgrade to 2.05 soon haha
In the meantime I will use this solution.
Have a great day and thanks again!
I hope we will upgrade to 2.05 soon haha
In the meantime I will use this solution.
Have a great day and thanks again!
The topic has been locked.