Adateconversiontoorfromanumericfieldcanbe specifiedwithanyWebSphereDataStagenumeric datatype.WebSphereDataStage performsthenecessarymodificationsandeithertranslatesanumeric fieldtothesourcedatatype shownaboveortranslatesa conversionresulttothenumericdatatypeof thedestination.For example,youcanusetheconversionmonth_day_from_datetoconvertadatetoan int8,ortoanint16,int32,dfloat,etc.
date formats
Fourconversions,string_from_date,ustring_from_date,date_from_string,andustring_from_date,takeas aparameterof theconversionadateformatoradateuformat.Theseformatsaredescribedbelow.The defaultformatof thedatecontainedinthestringisyyyy-mm-dd.
TheformatstringrequiresthatyouprovideenoughinformationforWebSphereDataStagetodeterminea completedate(eitherday,month, andyear,or yearand dayofyear).
dateuformat
Thedateuformatprovidessupport forinternationalcomponentsindatefields.It’ssyntax is:
String%macroString%macroString%macroString
where%macroisadateformattingmacrosuchas%mmm fora3-characterEnglishmonth. See177fora descriptionof thedateformatmacros.OnlytheStringcomponentsofdateuformatcaninclude
multi-byteUnicodecharacters.
dateformat
TheformatstringrequiresthatyouprovideenoughinformationforWebSphereDataStagetodeterminea completedate(eitherday,month, andyear,or yearand dayofyear).
Theformat_stringcancontainoneoracombinationofthefollowingelements:
Table4.Dateformattags Tag
Variablewidth
availability Description Valuerange Options
%d import Dayofmonth,
variablewidth
1...31 s
Table4.Dateformattags (continued)
%mmmm import/export Monthofyear,full
name,localespecific
January,February... t,u,w,-N,+N
%yy Yearofcentury 00...99 s
%yyyy Fourdigityear 0001...9999
%NNNNyy Cutoffyearplusyear
%W import Weekofyear(ISO
8601,Mon)
Whenyouspecifyadateformatstring, prefixeachcomponentwith thepercent symbol(%)andseparate thestring’scomponentswithasuitableliteralcharacter.
Thedefaultdate_formatis%yyyy-%mm-%dd.
Whereindicatedthetagscanrepresentvariable-widthdataelements.Variable-widthdateelementscan omitleadingzeroeswithoutcausingerrors.
Thefollowingoptionscanbe usedintheformatstringwhereindicatedinthetable:
s Specifythisoption toallowleadingspacesindateformats.Thes optionisspecifiedintheform:
%(tag,s)
Wheretag istheformatstring.Forexample:
%(m,s)
indicatesanumericmonthofyearfieldinwhichvaluescancontainleadingspacesorzeroesand beoneortwocharacterswide.Ifyouspecifiedthefollowingdateformatproperty:
%(d,s)/%(m,s)/%yyyy
Thenthefollowingdateswouldallbe valid:
8/ 8/1958 08/08/1958 8/8/1958
v Usethisoptioninconjunctionwiththe%dddtagtorepresentdayof yearinvariable-width format.Sothefollowingdateproperty:
%(ddd,v)
representsvaluesintherange1to366. (Ifyouomitthev optionthen therangeofvalueswould be001 to366.)
u Usethisoptiontorenderuppercase textonoutput.
w Usethisoptiontorenderlowercase textonoutput.
t Usethisoptiontorendertitlecasetext(initialcapitals)onoutput.
Theu,w,and toptionsaremutuallyexclusive.Theyaffecthow textisformattedforoutput.Inputdates willstill becorrectlyinterpretedregardlessofcase.
-N Specifythisoption toleftjustifylongdayormonthnamessothattheotherelementsinthedate willbe aligned.
+N Specifythisoption torightjustifylongdayormonthnamessothattheotherelementsinthe datewillbealigned.
Namesare leftjustifiedorrightjustifiedwithina fixedwidthfieldofNcharacters (whereNisbetween1 and99).Nameswillbetruncatedifnecessary. Thefollowingareexamplesofjustificationinuse:
%dd-%(mmmm,-5)-%yyyyy 21-Augus-2006
%dd-%(mmmm,-10)-%yyyyy 21-August -2005
%dd-%(mmmm,+10)-%yyyyy 21- August-2005
Thelocalefordeterminingthesettingofthedayandmonthnamescanbecontrolled throughthelocale tag.Thishastheformat:
%(L,’locale’)
Wherelocalespecifiesthelocaletobe setusingthelanguage_COUNTRY.variantnamingconvention supportedbyICU.SeeNLSGuidefora listof locales.Thedefaultlocaleformonthnamesandweekday namesmarkersisEnglishunlessoverriddenbya %LtagortheAPT_IMPEXP_LOCALEenvironment variable(thetagtakesprecedenceovertheenvironmentvariableif bothareset).
Usethelocaletagin conjunctionwithyour timeformat, forexampletheformatstring:
%(L,’es’)%eeee, %dd %mmmm %yyyy
SpecifiestheSpanish localeandwouldresult inadatewithethefollowingformat:
miércoles, 21 septembre 2005
Theformatstringissubjectto therestrictions laidoutinthefollowingtable.Aformatstringcancontain atmostonetagfromeachrow.Inadditionsomerowsaremutuallyincompatible,asindicatedinthe
’incompatiblewith’column.Whensometagsare usedtheformatstringrequiresthatothertagsare presenttoo,asindicatedinthe’requires’column.
Table5.Formattagrestrictions
Element Numericformattags Textformattags Requires Incompatiblewith
year %yyyy,%yy,
%[nnnn]yy
- -
-month %mm,%m %mmm,%mmmm year weekofyear
dayofmonth %dd,%d - month dayofweek,weekof
year
dayofyear %ddd year dayofmonth,dayof
week,weekofyear
dayofweek %e,%E %eee,%eeee month,weekofyear dayofyear
weekofyear %WW year month,dayofmonth,
dayofyear
Whena numericvariable-widthinputtagsuchas%dor%misused, thefieldtotheimmediaterightof thetag(if any)intheformatstringcannotbeeithera numerictag,ora literalsubstringthatstartswitha digit.Forexample,allofthefollowingformatstringsare invalidbecauseof thisrestriction:
%d%m-%yyyy
%d%mm-%yyyy
%(d)%(mm)-%yyyy
%h00 hours
Theyear_cutoffistheyeardefiningthebeginningofthecenturyinwhichalltwo-digityears fall.By default,theyearcutoff is1900;therefore,a two-digityearof97represents1997.
Youcanspecifyanyfour-digityearastheyearcutoff.All two-digityears thenspecifythenextpossible yearendinginthespecifiedtwodigitsthatisthesameor greaterthanthecutoff.Forexample,ifyouset theyearcutoff to1930,thetwo-digityear30correspondsto1930,andthetwo-digityear29corresponds to2029.
Onimportandexport,theyear_cutoffisthebase year.
Thispropertyismutuallyexclusivewithdays_since,text, andjulian.
Youcaninclude literaltextinyourdateformat.AnyUnicodecharacterotherthannull,backslash,orthe percentsigncanbeused(althoughitisbettertoavoidcontrolcodesandothernon-graphiccharacters).
Thefollowingtablelistsspecialtagsand escapesequences:
Tag Escapesequence
%% literalpercentsign
\% literalpercentsign
\n newline
\t horizontaltab
\\ singlebackslash
Forexample,theformatstring%mm/%dd/%yyyyspecifiesthatslashesseparatethestring’sdate components;theformat%ddd-%yyspecifiesthatthestringstoresthedateasa valuefrom1 to366, derivestheyearfromthecurrentyearcutoff of1900,andseparatesthetwocomponentswitha dash(-).
Thediagramshowsthemodification ofa datefieldtothreeintegers.Themodify operatortakes:
v
Thedayofthemonthportion ofadatefieldandwritesit toan8-bitinteger v Themonthportionofadatefieldandwrites ittoan8-bitinteger
v Theyearportionofa datefieldand writesittoa16-bit integer
Usethefollowingoshcommand:
$ osh "...| modify ’dayField = month_day_from_date(dField);
monthField = month_from_date(dField);
yearField = year_from_date(dField);’ | ..."