40
Views
7
Comments
Solved
Long Date
Question

Hi,


How can I output a DateTime field to display as , for example "1st January 2023".

I used the format date but I can only get to "1 January 2023". I need to add the suffix for the day number 


Also, I am outputting this value from a Service module so I do not have access to javascript. 

2022-10-18 07-32-49
Randall Jodache Chetty
Solution

See below. Its a pretty straight forward server action..

get the day (number)In English, there are just 4possible suffixes, namely, "st', "nd", "rd" and "th"
Check what number it is ...


add the appropriate suffix to the day (number)
the rest of the numbers will have "th" as the suffix

lastly , output the built up long date with position as a text 


I added the option to add time(as a Input = bool) as well which might be helpful
My action with variables looks like the following

2023-10-21 19-42-11
Tousif Khan
Champion

Hello
 you need to customize this you can create a function based on your input and it will return you the output with the suffix ordinary number.

Some reference that might help you - 

Thanks
Tousif Khan

2023-02-09 12-36-42
Damian Fonville

Hi,

You can use the foramtDateTime function, with the following format, "d MMMM yyyy ", Only this returns it without the ordinal suffix, 

The solution for this is to use a Forge compont like I made Number Ordinal Multi Language to parse the day to a ordinal string and use the FormatDateTime with the format "MMMM yyyy " and prepend the result of the Ordinal value with the formated date.


If you need any assistants with the code or need an example please let me know

2022-10-18 07-32-49
Randall Jodache Chetty

I ended up building my own server action that strips each section of the date and builds it back up into a full text 

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

If you are willing to share the same here and mark it as a solution. that would be a real help to the community having the same issue in future.

Thanks

2022-10-18 07-32-49
Randall Jodache Chetty

Thanks for the replies 

2023-10-27 12-06-14
Asiyah Munawwar

Hi Randall Jodache  Chetty ,

You can use this 

https://www.outsystems.com/forge/component-overview/15402/reactive-ordinal-date-format

This will help you to achieve what you want.

Thanks 

2022-10-18 07-32-49
Randall Jodache Chetty
Solution

See below. Its a pretty straight forward server action..

get the day (number)In English, there are just 4possible suffixes, namely, "st', "nd", "rd" and "th"
Check what number it is ...


add the appropriate suffix to the day (number)
the rest of the numbers will have "th" as the suffix

lastly , output the built up long date with position as a text 


I added the option to add time(as a Input = bool) as well which might be helpful
My action with variables looks like the following

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.