Zoho Deluge - Get Full Day Name

What?
This is a very quick note with the code to retrieve the full day name from a date (eg. "Monday").

Why?
If I use the toString() function to get the day, it only returns the first 3 letters of the day (eg. "Mon").
My_Date = today;
Day_Name = My_Date.toString("E");  // returns "Mon"
How?
Well a few methods.

Method #0: Update 2020
Tested in CRM and Creator and this is working:
My_Date = today;
Day_Name = My_Date.toString("EEEE");  // returns "Monday"

Method #1:
We're going to populate two arrays / lists; retrieve the index value; and use this in the second array as follows:
	// lists
	Day_Names = List:String({"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"});
	Day_Abbreviations = List:String({"Mon","Tue","Wed","Thu","Fri","Sat","Sun"});

	// get date field day abbreviation
	Day_Abbreviation = My_Date.toString("E");   

	// find in array and return same index from first array
	Day_Name = Day_Names.get(Day_Abbreviations.indexOf(Day_Abbreviation));	
Reducing the code lines but using the same technique as above:
	Day_Names = List:String({"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"});
	Day_Abbreviations = List:String({"Mon","Tue","Wed","Thu","Fri","Sat","Sun"});
	Day_Name = Day_Names.get(Day_Abbreviations.indexOf(My_Date.toString("E")));

Method #2:
Using a map, we can reduce this to two lines of code:
	Day_Map = {"Mon":"Monday","Tue":"Tuesday","Wed":"Wednesday","Thu":"Thursday","Fri":"Friday","Sat":"Saturday","Sun":"Sunday"};
	Day_Name = Day_Map.get(My_Date.toString("E"));

Method #3:
Using a list, the inevitable single line:
	Day_Name = ",Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".toList(",").get(My_Date.toDate().getDayOfWeek());

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.