Probleme beim Erhöhen jedes Datums in einer SpalteHallo,
Ich importiere Daten mit Zeitstempeln aus einer SQLite-Datei. Hier ist ein Zeitstempel als Beispiel: 2024-04-12T18:55:42.464558Z. Da JMP keine Mikrosekunden unterstützt, schneide ich die letzten 8 Zeichen ab und konvertiere die Spalte in ein Zeitformat. Bis hierhin scheint alles zu funktionieren. Wenn ich jedoch versuche, jeden Zeitstempel um 6 Stunden zu erhöhen (Zeitzonenunterschiede), werden alle Zeitstempel einfach gelöscht.
dt = Current Data Table(); // Gets the currently active data table
// Check if the "timestamp" column exists
If( Contains( dt << Get Column Names("String"), "timestamp"),
// Get the column reference
col = Column(dt, "timestamp");
// Truncate the last 8 characters from each value in the "timestamp" column
col << Set Each Value( Substr( Char( col ), 1, Length( Char( col ) ) - 8 ) );
// Convert the truncated timestamps to numeric datetime values
col << data type(numeric) << modeling type(continuous) << format("yyyy-mm-ddThh:mm:ss");
// Subtract 6 hours from each datetime value using Date Increment
For( i = 1, i <= N Rows(dt), i++,
If( !Is Missing( col[i] ),
col[i] = Date Increment( col[i], "Hour", -6 );
);
);
Show("Timestamps have been truncated and decremented by 6 hours.");
,
// Error handling if column does not exist
Show("Error: 'timestamp' column does not exist in the current data table.")
);Was wäre die richtige Art, die Zeitstempel grundsätzlich in ein für JMP akzeptables Format umzuwandeln und jeden Wert um -6 zu erhöhen? Vielen Dank!
Automatisierung und SkriptingBetreff: Probleme beim Erhöhen jedes Datums in einer SpalteWenn Sie keine Millisekunden möchten, können Sie meiner Meinung nach versuchen, Ihre SQL-Abfrage zu ändern und sie dort zu entfernen.
Haben Sie für Ihre Lösung versucht, dass Ihr Skript bis zum Subtraktionsteil das tut, was Sie erwarten? Sind die Spalten in numerische, fortlaufende und richtig formatierte Spalten geändert UND erkennt JMP sie als Daten (ändern Sie das Format in „Beste“ und Sie erhalten das Datenum-Format von JMP).
Betreff: Probleme beim Erhöhen jedes Datums in einer SpalteDanke für Ihren Beitrag. Ich habe es herausgefunden. Die Datumsinkrementfunktion erfordert einen numerischen Wert, daher musste der Zeitstempel vor der Verarbeitung in den richtigen Datentyp konvertiert werden. Ich musste auch „Stunde“ in „Sekunde“ ändern. Hier ist der funktionierende Code, falls jemand in Zukunft darauf stößt.
dt = Current Data Table(); // Gets the currently active data table
// Check if the "timestamp" column exists
If( Contains( dt << Get Column Names("String"), "timestamp"),
// Get the column reference
col = Column(dt, "timestamp");
// Process each row and remove the last 8 characters from the timestamp string
col << Set Each Value( Substr( :timestamp, 1, Length( :timestamp ) - 8 ) );
Show("Timestamps have been truncated.");
col << data type(numeric) << modeling type(continuous) << format("yyyy-mm-ddThh:mm:ss");
// Loop through each row in the column
For( i = 1, i <= N Rows(dt), i++,
// Read the value in the "timestamp" column for row i
timestamp_value = col[i];
numeric_datetime = Num( timestamp_value, Informat( "yyyy-mm-ddThh:mm:ss" ) );
numeric_datetime_adjusted = Date Increment(numeric_datetime, "second", -21600);
col[i] = numeric_datetime_adjusted;
);
,
// Error handling if column does not exist
Show("Error: 'timestamp' column does not exist in the current data table.")
);