Come convertire il timestamp UTC in ora locale in una formula di colonna
Ciao a tutti,
I have a column Timestamp UTC in JMP with values like 2025-10-31T08:30:00.
I want to create a new column Timestamp Local that converts this UTC time to local time
Is there a simple formula-based way to add 5.5 hours to my timestamp directly in a formula di colonna, without scripting or using Date Add?
Qualcosa del tipo:
Informat(:Timestamp UTC, "yyyy-mm-ddThh:mm:ss") + (4 * 3600)
ma non sono sicuro che questa sia la sintassi corretta poiché non produce errori di valutazione dei risultati né della formula
Ho provato anche basandomi su una discussione:
<'T'>
<HH24>
<::>
<MM>
<::>
<SS>
Z") + (4 * 3600)
</SS>
</MM>
</HH24>
- Nessun risultato
La formula è la seguente:
Also tried Format - "yyyy-mm-ddThh:mm:ss"
col_name_list = Current Data Table() << get column names( string );
If(
!Contains(col_name_list, "Timestamp Local"),
Current Data Table() << New Column(
"Timestamp Local",
Numeric,
Continuous,
Format("m/d/y h:m:s"),
Formula(
Informat(:Name("Timestamp UTC"),
//"Format Pattern",
"yyyy-mm-ddThh:mm:ss") + (4* 3600)
)
)
);
Informat(:Timestamp UTC, "Format Pattern", "
<YYYY>
<->
<MM>
<->
</MM>
</YYYY>
Gradirei ricevere indicazioni o esempi su come gestire in modo pulito le conversioni da UTC a locale all'interno delle formule di colonna.
Grazie!
Automazione e scriptingAnalisi e modellazione dei dati di baseCombinazione e pulizia dei datiRe: Come convertire il timestamp UTC in ora locale in una formula di colonnaÈ un'opzione?
![TimeAdd_2025-11-03 13_22_07-Time Plus - JMP [2].png TimeAdd_2025-11-03 13_22_07-Time Plus - JMP [2].png](https://us.v-cdn.net/6038925/uploads/images/86259i38E814A6E03787A1/TimeAdd_2025-11-03%2013_22_07-Time%20Plus%20-%20JMP%20%5B2%5D.png)
</CODE></PRE>
<P> </P>
<PRE><CODE class=" language-jsl">New Column( "Time Plus",
Numeric,
"Continuous",
Format( "yyyy-mm-ddThh:mm:ss", 19, 0 ),
Input Format( "yyyy-mm-ddThh:mm:ss", 0 ),
Formula( :Timestamp + In Hours( 5.5 ) ),
Set Selected
)
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaNew Table( "Untitled",
Add Rows( 2 ),
New Column( "old", Character, "Nominal", Set Values( {"2025-10-31T08:30:00", "2025-10-31T08:30:01"} ), Set Display Width( 153 ) ),
New Column( "new",
Numeric,
"Continuous",
Format( "Monddyyyy h:m:s", 22, 0 ),
Input Format( "Monddyyyy h:m:s", 0 ),
Formula( Informat( :old, "yyyy-mm-ddThh:mm:ss" ) + In Hours( 5.5 ) )
)
)

JMP memorizza i valori di data e ora come secondi numerici a partire dal 1904. La funzione InHours restituisce 3600 * l'argomento. Presumo che tu abbia dati di tipo carattere nella colonna Timestamp (vecchia, nel mio esempio).
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaAvrei dovuto aggiungerlo come riferimento.
Poiché si tratta di dati grezzi - tipo di modellazione - continuo
Formato definito come:
Format("m/d/y h:m:s")
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaAvrei dovuto aggiungerlo come riferimento.
Poiché si tratta di dati grezzi - tipo di modellazione - continuo
Formato definito come:
Format("m/d/y h:m:s")<BR /><BR />I tried the formula above, it didn't yeild any output. I will check again.
Re: Come convertire il timestamp UTC in ora locale in una formula di colonna@mlo1 @Craige_Hales
Ha funzionato.
col_name_list = Current Data Table() << get column names( string );
If( !Contains( col_name_list, "Timestamp Local" ), //If the column name doesn't exist in the array col_name_list
Current Data Table() << New Column(
"Timestamp Local",
Numeric,
"Continuous",
Format( "m/d/y h:m:s", 22, 0),
//Input Format( "Monddyyyy h:m:s", 0 ),
Formula(
//In Format( :Timestamp UTC, "yyyy-mm-ddThh:mm:ss" ) + In Hours( 5.5 )
Informat( Substitute(:Timestamp UTC, "+00:00", ""), "yyyy-mm-dd hh:mm:ss" ) + In Hours(5.5)
),
//Formula( :Timestamp + In Hours( 5.5 ) ),
//Set Selected
)
);<BR /><BR />
| Ora UTC |
Ora locale |
| 2025-09-14 07:51:52+00:00 |
14/09/2025 13:21:52 |
| 2025-09-14 07:56:52+00:00 |
14/09/2025 13:26:52 |
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaTuttavia, questa formula non funziona
If(!Contains(col_name_list, "Max Timestamp UTC"),
Current Data Table() << New Column(
"Max Timestamp UTC",
Numeric,
Continuous,
Format("m/d/y h:m:s", 22, 0),
Formula(
Col Maximum(
:Name("Timestamp UTC"),
/*Informat(
Substitute(:Name("Timestamp UTC"), "+00:00", ""),
"yyyy-mm-dd hh:mm:ss"
),*/
:Name("ID")
)
)
)
);
La versione così com'è, la parte commentata del codice sembra impiegare più tempo e finisce in un ciclo infinito, poiché fa sì che il mio JMP non risponda e io debba chiudere l'applicazione.
L'ho già fatto in precedenza, ma il timestamp locale viene generato senza utilizzare il codice sottostante.
:Name("Timestamp UTC") << Data Type(Character) << Modeling Type(Nominal);
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaQuale versione di JMP stai utilizzando? Se riscontri problemi di velocità con Col Max, creerei prima una colonna separata con
Informat(Substitute(:"Timestamp UTC"n, "+00:00", ""), "yyyy-mm-dd hh:mm:ss")
e quindi utilizzare la colonna appena creata come variabile.
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaSì, ci avevo provato
dt:Name( "Timestamp UTC" ) << Informat(
Substitute( :Timestamp UTC, "+00:00", "" ),
"yyyy-mm-dd hh:mm:ss"
);
dt:Name( "Timestamp UTC" ) << Data Type( Character ) << Modeling Type( Nominal );
col_name_list = Current Data Table() << get column names ( string );
If( !Contains(col_name_list, "Timestamp UTC (Numeric)"),
Current Data Table() << New Column(
"Timestamp UTC (Numeric)",
Numeric,
"Continuous",
Format("m/d/y h:m:s", 22, 0),
Formula(
Informat( Substitute(:Timestamp UTC, "+00:00", ""), "yyyy-mm-dd hh:mm:ss" )
)
)
);
dt:Name("Timestamp UTC (Numeric)") << Delete Formula;
dt:Name("Timestamp UTC") <<
Set Values(:Name("Timestamp UTC (Numeric)")) <<
Data Type(Numeric) <<
Format("m/d/y h:m:s", 22, 0);
Sto provando questo. Sta sovrascrivendo la mia colonna timestamp UTC e non ci sono valori
Re: Come convertire il timestamp UTC in ora locale in una formula di colonnaPuoi fornire un esempio della tabella che stai utilizzando? Dovrebbero bastare solo le colonne timestamp (ricordati anche di eliminare variabili/script della tabella).
Re: Come convertire il timestamp UTC in ora locale in una formula di colonna@jthi Consiglia questa soluzione. Ho scoperto che creare una colonna extra e usarla è semplicissimo.