Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
norman in
307
Views
13
Comments
Date Conversion
Question
if i want to convert a numerical month into a string ex: 01 into Jan (without using ADV queries), is there a way to do it?
Thx
J.
Â
MVP
yes, with an action.
simple switch statement should be the "easiest" way
Curt Raddatz
Create a static entity with ID values (change data type to text if needed) of 01-12 and Label values of January through December. Then, in your simple query, just have a join between the month number and the static table ID and add the Label field to the list of result fields. Easy!!
Hope this helps,
Curt
norman in
thank you althought i was trying to avoid doing that too :P but thx anyway
Curt Raddatz
Ok, so you want a solution but you are not willing to do the two minutes of work it will take? I guess we need a platform that reads minds.
<< Sorry for the sarcasm. I was not going to say anything but you asked for help, you received two easy solutions within one hour and you're not willing to implement either of them? I don't understand. >>
kota
Norman, You can also have a look at
https://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.getmonthname(v=vs.90).aspx
You can create an extension to use it in outsystems.
norman in
oh its not that Curt, sorry for the mistunderstand, i was avoinding the use of adv query for it requires the use of database, and i cant use database since, im still bootstraping them :(, so the database still doesnt exist
Curt Raddatz
None of the suggestions use an advanced query. If you are trying to convert the numeric values to the names of the months as part of the bootstrap process that's easy enough to do using what Stalter provided, but doing so is not a good database design decision. To help more we'd have to try and understand what you are ultimately trying to do.
norman in
well what i was exactly trying to do that, receiving a resource "an excel sheet" that has a date time column, but when i bootstrap it, i want to convert it in to a string and get the month of that date time column in to an entity atribute, just that.
but since using switch seems bad implemantation... gonna see if in the assignment widget i can find any function that helps...
Izak Joubert
Since someone mentioned advanced queries, I thought I'd add this option as well. You can use an advanced query without a database table existing.
1 Create a structure (e.g. Month) in you espace with a single text attribute (e.g.Name)
2 Create an advanced query (e.g. GetMonthName) in you action that has an integer @month input parameter and uses the newly created Month structure as the output.
3 Use the folowing for the query:
SELECT
CASE
WHEN @month = 1 THEN 'Jan'
WHEN @month = 2 THEN 'Feb'
WHEN @month = 3 THEN 'Mar'
WHEN @month = 4 THEN 'Apr'
WHEN @month = 5 THEN 'May'
WHEN @month = 6 THEN 'Jun'
WHEN @month = 7 THEN 'Jul'
WHEN @month = 8 THEN 'Aug'
WHEN @month = 9 THEN 'Sep'
WHEN @month = 10 THEN 'Oct'
WHEN @month = 11 THEN 'Nov'
WHEN @month = 12 THEN 'Dec'
ELSE ''
END
In the action flow after the advanced query is executed, you can use GetMonthName.Month.Name.Value to get the correct text value.
If you place all of this in a logic action with the appropriate input and output parameters, you have a nice reusable function.
João Rosado
Staff
Hi,
The best sugestion is Statler's one, followed by kota's as second choice.
I would stay away from database if something can be done in actions...since usually database is always the performance bottleneck on applications.
Regards,
João Rosado
Izak Joubert
Agreed. My suggestion was simply to illustrate that it could be done without a table present.
norman in
ok thank you all for the sugestions
Ashish-S
Why not create a dummy date and caste it to month!! Just thinking out loud,
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
 Loading...