What?
This is a very quick note with the code to determine the English ordinal of a date (eg. "st" of "1st"). So in a date, instead of "Tuesday, 6 November 2018", I could want "Tuesday 6th of November 2018".
Why?
Well there's a long a way to do it (but reliable). But being limited to the lines of code you can run (ref. "Maximum number of executable statements", anything that reduces the number of lines used would be an improvement. This is how I was doing it previously.
copyrawstyler
// get the date (eg. 1, 2, 3, ... 29, 30, 31)
This_Day_Date = My_Date_Field.toString("d");
// determine English ordinal
English_Ordinal = "th ";
if(This_Day_Date == "1" || This_Day_Date == "21" || This_Day_Date == "31")
{
English_Ordinal = "st ";
}
if(This_Day_Date == "2" || This_Day_Date == "22")
{
English_Ordinal = "nd ";
}
if(This_Day_Date == "3" || This_Day_Date == "23")
{
English_Ordinal = "rd ";
}
// display
info My_Date.toString("d") + English_Ordinal;
- This_Day_Date = My_Date_Field.toString("d");
-
- English_Ordinal = "th ";
- if(This_Day_Date == "1" || This_Day_Date == "21" || This_Day_Date == "31")
- {
- English_Ordinal = "st ";
- }
- if(This_Day_Date == "2" || This_Day_Date == "22")
- {
- English_Ordinal = "nd ";
- }
- if(This_Day_Date == "3" || This_Day_Date == "23")
- {
- English_Ordinal = "rd ";
- }
-
- info My_Date.toString("d") + English_Ordinal;
How?Category: Zoho :: Article: 655