Convert Number into Ordinal

Convert Number into Ordinal

Hello Developers,

Here is the solution for converting the Number into Ordinal.

For Example:

This Idea can be used when lets say you are creating the Dashboard  where you are showing upcoming celebrations like work Anniversary for you HRMS Application.

Once employee completes 1 year then it will show 1st Anniversary and say if completes 2 years the it will show 2nd Anniversary.

To Achieve this just create a custom function which take input as Number and Return String please find the deluge script for the same below.

  1. string getOrdinal(int n)
  2. {
  3. ord = "th";
  4.   if (n % 10 == 1 && n % 100 != 11)
  5.   {
  6. ord = "st";
  7.   }
  8.   else if (n % 10 == 2 && n % 100 != 12)
  9.   {
  10. ord = "nd";
  11.   }
  12.   else if (n % 10 == 3 && n % 100 != 13)
  13.   {
  14. ord = "rd";
  15.   }

  16.   return n + ord;
  17. }
  18.  

Hope this helps!

Regards, 
Anurag Jaiswal
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方