getDayNameShort β GTM Variable Template for Date
getDayNameShort CORE Date
Returns the abbreviated name of the day of the week. 1 = Mon, 7 = Sun (ISO 8601).
When to Use This
Section titled βWhen to Use ThisβDate Formatting
Format and transform date values into human-readable or machine-readable strings.
Examples
Section titled βExamplesβIndex 1 returns Mon
INPUT
Day Index: 1
OUTPUT
Mon
Invalid index returns undefined
INPUT
Day Index: 10
OUTPUT
undefined
Live Sandbox
Section titled βLive SandboxβThis is what you'll see when you open this variable in Google Tag Manager. Hover the icons for details.
getDayNameShort
Day Index
πΎ An ISO 8601 day number (1 = Monday, 7 = Sunday).
Supported formats:
β Number
β String
Supported formats:
β Number
β String
Input Setup
Input Function (optional)
βοΈ Optional pre-processing function applied to the input before internal logic (e.g., convert object to string, normalize case). Internal transformations such as case handling will still apply afterward.
Result Handling
Output Function (optional)
βοΈ Optional function to apply to the result before returning it (e.g., str => str + ' β¬', val => val !== undefined for boolean conversion). Useful for chaining transformations on the output.
Day Index number
π‘ Type any text to see the result update live
π― Using special value β click input to type instead
Test with:
Falsy
Truthy
π Result Handling β Chain Variables
Chain apply-mode variables to the output. Each variable receives the result of the previous one.
getDayName()
Related Variables
Section titled βRelated VariablesβSame category: Date
Under the Hood
Section titled βUnder the Hoodβπ View Implementation Code
/*** Returns the abbreviated name of the day of the week based on the given integer where 0 = Monday, 1 = Tuesday, etc.** @param {number|string} data.src - An integer representing the day of the week (0 to 6).* @param {Function|string} [data.out] - Optional output handler: function to transform result or string with format.** Direct-mode specific parameters:* @param {Function} [data.pre] - Optional pre-processor function to transform src before conversion.** @returns {string|undefined} The abbreviated name of the day (e.g., "Mon", "Tues", etc.), or undefined if the index is invalid.** @framework ggLowCodeGTMKit*/const makeNumber = require('makeNumber');
const getDayName = function(dayInt) { const day = makeNumber(dayInt); if (day < 1 || day > 7) return undefined; const dayList = ["Mon", "Tues", "Wed", "Thu", "Fri", "Sat", "Sun"]; return dayList[day - 1];};
const safeFunction = fn => typeof fn === 'function' ? fn : x => x;const out = safeFunction(data.out);
// ===============================================================================// getDayName - Direct mode// ===============================================================================const applyCast = (castFn, value) => safeFunction(castFn)(value);const value = applyCast(data.pre, data.src);return out(getDayName(value));
// ===============================================================================// getDayName() β Apply Mode: runtime parameter// ===============================================================================/*return function(value) { return out(getDayName(value));};*/π§ͺ View Test Scenarios (4 tests)
β
'[example] Index 1 returns Mon'β
Valid day index 4 - returns Thursdayβ
Valid day index 7 - returns Sundayβ
'[example] Invalid index returns undefined'