2022.2

Table Of Contents
pattern
String.Thecustompatternmayconsistofpatternletters,separatingsymbolsandquotedtext,for
example:"'at'HH:mm:ssz";see"Dateandtimepatterns"onthenextpage.Notethattherepetitionof
patternlettersdeterminestheexactpresentation.
timeLong(value)
Formatsatimeaslongstringrepresentation,forexample12:00:00 EDT AM.
value
ADateobject.ADatecancontainadateandtime.
timeMedium(value)
Formatsatimeasmediumstringrepresentation,forexample12:00:00 AM.
value
ADateobject.ADatecancontainadateandtime.
timeShort(value)
Formatsatimeasshortstringrepresentation,forexample12:00 AM.
value
ADateobject.ADatecancontainadateandtime.
Examples
Creating a Date object from a string
WhenyouopenadatafileordatabaseintheDesigner,allfieldsaretextfields(fieldsofthetype
string).Theformattercannotbeusedtoformatastringwithaparticulardateformat.Thesolution
istostorethestringinavariableasaDateobject,andusetheformatterwiththatvariable.
Thefollowingsamplescriptdemonstratesthissolution.Itsplitsastringintopartsandthencreatesa
newDateobjectwiththepartsinthecorrectorder.ToconstructaDate,thepartsofthedatemustbe
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]);
Page 723