열의 각 날짜를 증가시키는 문제안녕하세요,
SQLite 파일에서 타임스탬프가 있는 데이터를 가져오려고 합니다. 예를 들어 타임스탬프는 다음과 같습니다: 2024-04-12T18:55:42.464558Z. JMP는 마이크로초를 지원하지 않기 때문에 마지막 8자를 잘라내고 열을 시간 형식으로 변환합니다. 이 시점까지는 모든 것이 작동하는 것 같습니다. 그러나 각 타임스탬프를 6시간(시간대 차이)씩 늘리려고 하면 모든 타임스탬프가 간단하게 삭제됩니다.
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.")
);기본적으로 타임스탬프를 JMP에 허용되는 형식으로 변환하고 각 값을 -6씩 증가시키는 올바른 방법은 무엇입니까? 감사합니다!
자동화 및 스크립팅Re: 열의 각 날짜를 증가시키는 데 문제가 있습니다.밀리초를 갖고 싶지 않다면 SQL 쿼리를 수정하고 거기에서 제거해 볼 수 있다고 생각합니다.
솔루션의 경우 빼기 부분까지 스크립트가 예상한 대로 작동하도록 시도해 보셨나요? 열이 연속적이고 올바른 형식의 숫자로 변경되었으며 JMP는 이를 날짜로 인식합니다(형식을 최상으로 변경하면 JMP의 날짜 숫자 형식을 얻습니까).
Re: 열의 각 날짜를 증가시키는 문제귀하의 의견에 감사드립니다. 알아냈어요. 날짜 증분 기능에는 숫자 값이 필요하므로 처리하기 전에 타임스탬프를 올바른 데이터 유형으로 변환해야 했습니다. 또한 "Hour"를 "Second"로 변경해야 했습니다. 나중에 누군가가 이 문제를 겪을 경우 작동하는 코드는 다음과 같습니다.
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.")
);