2022.2

Table Of Contents
putinthefollowingorder:year,month,day,andoptionallyhours,minutes,seconds,milliseconds(see
https://www.w3schools.com/js/js_dates.aspandhttps://developer.mozilla.org/en-US/-
docs/Web/JavaScript/Reference/Global_Objects/Date.)Whenthetimeisomitted,itdefaultsto
12:00:00AM.
/* Convert the string 21-12-1997 into a valid JavaScript date */
var strDate = record.fields["date"];
var dateParts = strDate.split("-");
var date = new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);
Note: JavaScriptcountsmonthsfrom0to11.Januaryis0.Decemberis11.
AnotherwaytoputastringinaDateistousetheDate.parsefunction;seehttps://developer-
.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse.
Thedatevariablecanbeusedasthevalueinthedate,dateTimeortimefunctionsoftheformatter.
var myDate = formatter.date(date, "MM/dd/yyyy");
Thecustompatternthatthescriptprovides,outputsthemonthanddayintwodigitseachandtheyear
infourdigits:05/21/2016.Formoreexamplesofformattingpatterns,see"Dateandtimepatterns"
below.
Date and time patterns
Datesandtimesinatemplateoriginatingfromadatefieldinarecordsetcanbedisplayedusingacus-
tompattern.YoucanenterthepatternviatheHelperWizardortheTextScriptWizard,lestthefield
typeissettoDateinadatamappingconfigurationandthefieldcontainsavaliddate;see"Usingthe
HelperWizard"onpage725,"UsingtheTextScriptWizard"onpage729and"Formattingvariable
data"onpage732.IntheScriptEditor,thepatterncanbepassedtoadate,dateTimeorTimefunction
oftheformatter;see"formatter"onpage1175.
Thecustompatternmayconsistofpatternletters(seebelow),forexample:"MM/dd/yyyy".Thecom-
ponentscanbeseparatedwithaspaceorasymbol,e.g..,/,-.Textmustbeputinquotes.
Therepetitionofpatternlettersdeterminestheexactpresentation.Forexample,ifthenumberofpat-
ternlettersforamonthislessthan3(MorMM),themonthisdisplayedasanumber.Ifthenumberof
patternlettersis3(MMM),itwillbedisplayedastext;ifavailable,ashortorabbreviatedformofthe
month'snamewillbeused.Ifthenumberofpatternlettersis4ormore(MMMM),themonth'sfullname
isdisplayed.
Note: Thepatternlettersandpatternsonthispageareonlysuitablefordisplayingdatesand
timesintemplates,notforextractingdatesintheDataMappermodule.Forpatternlettersandpat-
ternsavailableintheDataMapper,see"Date"onpage278.
Page 1180