cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-84776%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20al%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84776%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%C2%A1Hola%20a%20todos!%3C%2FP%3E%3CP%3EC%C3%B3mo%20utilizar%20JSL%20o%20f%C3%B3rmula%20para%20convertir%20el%20texto%20de%20la%20columna%201%20al%20formato%20de%20hora%20de%20la%20columna%202.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%C2%A1Gracias!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222018-11-30_22-27-38.png%22%20style%3D%22width%3A%20779px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222018-11-30_22-27-38.png%22%20style%3D%22width%3A%20779px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14655i41B6AFADC1D54FDD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222018-11-30_22-27-38.png%22%20alt%3D%222018-11-30_22-27-38.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-376895%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-376895%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EAqu%C3%AD%20hay%20un%20formato%20que%20funcionar%C3%A1%20con%20los%20ejemplos%20que%20proporcion%C3%B3.%20Tendr%C3%A1%20que%20modificarse%20para%20otras%20combinaciones%20de%20valores%20y%20estructura.%20Se%20adjunta%20una%20tabla%20de%20datos%20de%20muestra%20con%20la%20f%C3%B3rmula%20aplicada.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EIf(%20Row()%20%3D%3D%201%2C%0A%09moList%20%3D%20%7B%22January%22%2C%20%22February%22%2C%20%22March%22%2C%20%22April%22%2C%20%22May%22%2C%20%22June%22%2C%20%22July%22%2C%0A%09%22August%22%2C%20%22September%22%2C%20%22October%22%2C%20%22November%22%2C%20%22December%22%7D%3B%0A%09moAbvList%20%3D%20%7B%22Jan%22%2C%20%22Feb%22%2C%20%22Mar%22%2C%20%22Apr%22%2C%20%22May%22%2C%20%22Jun%22%2C%20%22Jul%22%2C%20%22Aug%22%2C%20%22Sep%22%2C%0A%09%22Oct%22%2C%20%22Nov%22%2C%20%22Dec%22%7D%3B%0A)%3B%0AIf(%0A%09Word(%203%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20%3D%3D%20%22%22%2C%0A%09%09theDay%20%3D%20Num(%20Substr(%20%3AMdfc%2C%201%2C%202%20)%20)%3B%0A%09%09theMonth%20%3D%20Contains(%20moAbvList%2C%20Substr(%20%3AMdfc%2C%204%2C%203%20)%20)%3B%0A%09%09theYear%20%3D%20Num(%20Word(%20-1%2C%20%3AMdfc%2C%20%22abcdefghijklmnopqrstuvwxyz%22%20)%20)%3B%0A%09%09Show(%20theday%2C%20themonth%2C%20theyear%2C%20Substr(%20%3AMdfc%2C%204%2C%203%20)%20)%3B%2C%0A%09Is%20Missing(%20Num(%20Word(%202%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%20)%20%3D%3D%201%2C%0A%09%09theDay%20%3D%20Num(%20Word(%201%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A%09%09theMonth%20%3D%20Contains(%20moList%2C%20Word(%202%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A%09%09theYear%20%3D%20Num(%20Word(%203%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%2C%0A%09Is%20Missing(%20Num(%20Word(%201%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%20)%20%3D%3D%201%2C%0A%09%09theDay%20%3D%20Num(%20Word(%202%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A%09%09theMonth%20%3D%20Contains(%20moList%2C%20Word(%201%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A%09%09theYear%20%3D%20Num(%20Word(%203%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%2C%0A%09theDay%20%3D%20Num(%20Word(%202%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A%09theMonth%20%3D%20Num(%20Word(%201%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A%09theYear%20%3D%20Num(%20Word(%203%2C%20%3AMdfc%2C%20%22%20%2F-%22%20)%20)%3B%0A)%3B%0ADate%20MDY(%20theMonth%2C%20theDay%2C%20theYear%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-376832%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-376832%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ETengo%20un%20dato%20con%20una%20variable%20que%20puede%20incluir%20diferentes%20tipos%20de%20fechas.%3CBR%20%2F%3E%20Ejemplo%3A%3CBR%20%2F%3E%2017%20de%20enero%20de%202015%3CBR%20%2F%3E%20O%3CBR%20%2F%3E%2012-6%2F2013%3CBR%20%2F%3E%20O%3CBR%20%2F%3E%2020%20de%20enero%20de%201997%3CBR%20%2F%3E%20O%3CBR%20%2F%3E%2026%20de%20marzo%20de%202001%3CBR%20%2F%3E%20O%3CBR%20%2F%3E%2023-12-1991%3CBR%20%2F%3E%20Cambiar%C3%A1n%20en%20c%C3%B3digo.%3CBR%20%2F%3E%20Entonces%2C%20necesito%20tener%20la%20fecha%20en%20formato%20AAAA-MM-DD%20en%20mi%20segunda%20variable.%3CBR%20%2F%3E%3CBR%20%2F%3E%20La%20primera%20var%20es%20Mdfc%3CBR%20%2F%3E%20La%20segunda%20Var%20es%20Fdtc.%3CBR%20%2F%3E%3CBR%20%2F%3E%20%C2%BFPuedes%20ayudar%20a%20tener%20la%20soluci%C3%B3n%3F%3CBR%20%2F%3E%20Gracias%20!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84902%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84902%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EEse%20es%20el%20estilo%2C%20%C2%A1gracias!%3CBR%20%2F%3E%3CBR%20%2F%3E%20%3CSPAN%3EEl%20efecto%20es%20el%20mismo%3A%3C%2FSPAN%3E%3CBR%20%2F%3E%20%3CSPAN%3Eformato(x%2C%20%22a%2Fm%2Fd%22)%20%E2%80%94%E2%80%94%E2%80%94%E2%80%94%3C%2FSPAN%3E%20formato(x%2C%20%22aaaaammdd%22)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84883%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84883%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ELa%20funci%C3%B3n%20%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2F14%2Fdate-and-time-functions.shtml%232531887%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EFormat()%3C%2FA%3E%20se%20utiliza%20para%20convertir%20una%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJMPer-Cable%2FUsing-dates-times-datetimes-and-durations-in-JMP%2Fba-p%2F68689%22%20target%3D%22_self%22%3Efecha%2C%20hora%20o%20valor%20de%20fecha%20y%20hora%20JMP%3C%2FA%3E%20en%20una%20cadena%20de%20texto.%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3EPor%20ejemplo%3A%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ex%3Dinformat(%2220000214%22)%3B%0A%0Ashow(format(x%2C%20%22m%2Fd%2Fy%22))%3B%0A%0Ashow(format(x%2C%20%22d%2Fm%2Fy%22))%3B%0A%0Ashow(format(x%2C%20%22Date%20Long%22))%3B%0A%0Ashow(format(x%2C%20%22Monddyyyy%22))%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EResultados%20en%20esto%20en%20el%20registro%3A%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CPRE%3EFormat(x%2C%20%22m%2Fd%2Fy%22)%20%3D%20%2202%2F14%2F2000%22%3B%0AFormat(x%2C%20%22d%2Fm%2Fy%22)%20%3D%20%2214%2F02%2F2000%22%3B%0AFormat(x%2C%20%22Date%20Long%22)%20%3D%20%22Monday%2C%20February%2014%2C%202000%22%3B%0AFormat(x%2C%20%22Monddyyyy%22)%20%3D%20%22Feb142000%22%3B%3C%2FPRE%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84875%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84875%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ETu%20pregunta%20es%20vaga.%20Proporcione%20un%20ejemplo%20de%20c%C3%B3mo%20se%20ven%20los%20valores%20de%20entrada%20y%20cu%C3%A1l%20desea%20que%20sea%20el%20valor%20de%20salida...%E2%80%A6.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84865%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84865%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%C2%BFC%C3%B3mo%20puede%20JMP%20obtener%20el%20texto%20del%20a%C3%B1o%2C%20mes%20y%20d%C3%ADa%20a%20partir%20del%20formato%20de%20fecha%3F%3CBR%20%2F%3E%20Perd%C3%B3n%20por%20molestarte%20de%20nuevo%2C%20%C2%A1gracias!%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222018-12-04_22-10-39.png%22%20style%3D%22width%3A%20312px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%222018-12-04_22-10-39.png%22%20style%3D%22width%3A%20312px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14680iE047F7CDBE905FDD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222018-12-04_22-10-39.png%22%20alt%3D%222018-12-04_22-10-39.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84805%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84805%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%C2%A1Gracias!%3CBR%20%2F%3E%20Jim%20D%C3%A9jame%20saber%20el%20principio%2C%20Jeff_Perkinson%20d%C3%A9jame%20aprender%20la%20funci%C3%B3n%20JMP.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84799%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84799%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ELa%20f%C3%B3rmula%20de%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2687%22%20target%3D%22_blank%22%3E%40txnelson%3C%2FA%3E%20funcionar%C3%A1%2C%20pero%20hay%20una%20f%C3%B3rmula%20un%20poco%20m%C3%A1s%20simple%20que%20tambi%C3%A9n%20funcionar%C3%A1.%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JMPScreenSnapz300.png%22%20style%3D%22width%3A%20726px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22JMPScreenSnapz300.png%22%20style%3D%22width%3A%20726px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14661i7EBCFD2ABAB3F5B8%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22JMPScreenSnapz300.png%22%20alt%3D%22JMPScreenSnapz300.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EEste%20usa%20%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2F14%2Fdate-time-functions.shtml%23123225%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EInformat()%3C%2FA%3E%20para%20convertir%20los%20valores%20de%20fecha%20y%20hora.%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EInformat(%20Word(%201%2C%20%3AColumn%201%20)%20)%20%2BInformat(%20Word(%202%2C%20%3AColumn%201%20)%2C%20%22h%3Am%22%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84780%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84780%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EAqu%C3%AD%20est%C3%A1%20la%20f%C3%B3rmula%20para%20la%20conversi%C3%B3n.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EDate%20DMY(%0A%09Num(%20Substr(%20%3Adate%2C%207%2C%202%20)%20)%2C%0A%09Num(%20Substr(%20%3Adate%2C%205%2C%202%20)%20)%2C%0A%09Num(%20Substr(%20%3Adate%2C%201%2C%204%20)%20)%20)%20%2B%20%0A%0960%20*%2060%20*%20Num(%20Word(%202%2C%20%3Adate%2C%20%22%20%3A%22%20)%20)%20%2B%20%0A%0960%20*%20Num(%20Word(%20-1%2C%20%3Adate%2C%20%22%20%3A%22%20)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84777%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20convertir%20n%C3%BAmeros%20en%20formato%20de%20texto%20a%20formato%20aaaammdd%20hh%3Amm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84777%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELos%20nombres%20de%20las%20columnas%20en%20el%20diagrama%20deben%20ser%3CBR%20%2F%3E%20aaaammdd%20hh%3Amm%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
lwx228
Level VIII

How to convert text format Numbers to yyyymmdd hh:mm format?

Hello, everyone!

How to use JSL or formula to convert the text of column 1 into the time format of column 2.

 

Thanks!

2018-11-30_22-27-38.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Here is the formula for the conversion

Date DMY(
	Num( Substr( :date, 7, 2 ) ),
	Num( Substr( :date, 5, 2 ) ),
	Num( Substr( :date, 1, 4 ) ) ) + 
	60 * 60 * Num( Word( 2, :date, " :" ) ) + 
	60 * Num( Word( -1, :date, " :" ) )
Jim

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

@txnelson's formula will work but there's a slightly simpler formula that will work also.

 

JMPScreenSnapz300.png

This one uses Informat() to convert the date and time values. 

 

 

Informat( Word( 1, :Column 1 ) ) +Informat( Word( 2, :Column 1 ), "h:m" )

 

-Jeff

View solution in original post

10 REPLIES 10
lwx228
Level VIII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

The column names in the diagram should be
yyyymmdd hh:mm
txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Here is the formula for the conversion

Date DMY(
	Num( Substr( :date, 7, 2 ) ),
	Num( Substr( :date, 5, 2 ) ),
	Num( Substr( :date, 1, 4 ) ) ) + 
	60 * 60 * Num( Word( 2, :date, " :" ) ) + 
	60 * Num( Word( -1, :date, " :" ) )
Jim
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

@txnelson's formula will work but there's a slightly simpler formula that will work also.

 

JMPScreenSnapz300.png

This one uses Informat() to convert the date and time values. 

 

 

Informat( Word( 1, :Column 1 ) ) +Informat( Word( 2, :Column 1 ), "h:m" )

 

-Jeff
lwx228
Level VIII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Thanks!
Jim Let me know the principle, Jeff_Perkinson let me learn JMP function.
lwx228
Level VIII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

How can JMP get the text of year, month and day from the date format?
Sorry to bother you again,Thank you!

 

2018-12-04_22-10-39.png

 

 

 

txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Your question is vague. Please give an example of what the input values looks like, and what you want the output value to be...….
Jim
Alina199121
Level I

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

I have one data with one varieble that can inculde diferent types of dates.
Exmple:
17 January 2015
Or
12-6/2013
Or
20.Jan1997
Or
March 26 2001
Or
12-23-1991
They will changed in code.
So, I need to have date in YYYY-MM-DD format in my second variable.

First var is Mdfc
Second Var is Fdtc

Can you help to have the solution?
Thank you !
txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Here is a format that will work with the examples you provided.  It will have to be tweaked for other combinations of values and structure.  Attached is a sample data table with the formula applied

If( Row() == 1,
	moList = {"January", "February", "March", "April", "May", "June", "July",
	"August", "September", "October", "November", "December"};
	moAbvList = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
	"Oct", "Nov", "Dec"};
);
If(
	Word( 3, :Mdfc, " /-" ) == "",
		theDay = Num( Substr( :Mdfc, 1, 2 ) );
		theMonth = Contains( moAbvList, Substr( :Mdfc, 4, 3 ) );
		theYear = Num( Word( -1, :Mdfc, "abcdefghijklmnopqrstuvwxyz" ) );
		Show( theday, themonth, theyear, Substr( :Mdfc, 4, 3 ) );,
	Is Missing( Num( Word( 2, :Mdfc, " /-" ) ) ) == 1,
		theDay = Num( Word( 1, :Mdfc, " /-" ) );
		theMonth = Contains( moList, Word( 2, :Mdfc, " /-" ) );
		theYear = Num( Word( 3, :Mdfc, " /-" ) );,
	Is Missing( Num( Word( 1, :Mdfc, " /-" ) ) ) == 1,
		theDay = Num( Word( 2, :Mdfc, " /-" ) );
		theMonth = Contains( moList, Word( 1, :Mdfc, " /-" ) );
		theYear = Num( Word( 3, :Mdfc, " /-" ) );,
	theDay = Num( Word( 2, :Mdfc, " /-" ) );
	theMonth = Num( Word( 1, :Mdfc, " /-" ) );
	theYear = Num( Word( 3, :Mdfc, " /-" ) );
);
Date MDY( theMonth, theDay, theYear );
Jim
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

The Format() function is used to convert a JMP date, time or datetime value to a text string.

 

For example:

 

x=informat("20000214");

show(format(x, "m/d/y"));

show(format(x, "d/m/y"));

show(format(x, "Date Long"));

show(format(x, "Monddyyyy"));

Results in this in the log:

 

Format(x, "m/d/y") = "02/14/2000";
Format(x, "d/m/y") = "14/02/2000";
Format(x, "Date Long") = "Monday, February 14, 2000";
Format(x, "Monddyyyy") = "Feb142000";

 

 

-Jeff

Recommended Articles