TimeTemp
這樣顯示168@06:43:23AM
stationTime
顯示服務區車站的開放和關閉時間6AM-10AM
我已經TimeTemp
分成 2 個不同的列,initialTemp
并且initialTempTime
我已經stationTime
分成 2 個不同的列,openingTime
并且closingTime
所需的條件陳述句是“如果不是在每2小時間隔內,則將initialTemp
單元格變為紅色”,因此邏輯如下:
if(initialTempTime <= openingTime 2, green(), red())
initialTemp
如果運算式<=
為真,它應該變成綠色,否則變成紅色。然而,這已經將initialTemp
細胞全部變成紅色。
這讓我懷疑運算式沒有被正確評估,只是默認為else
. 我相信情況確實如此,因為initialTempTime
,openingTime
已被確認為文本字串資料型別。
由于 astring int
無法評估為真值,red()
因此默認將所有initialTemp
單元格變為紅色。
解決方案是將字串型別轉換為 int,這樣openingTime
可以6AM
增加 2 小時,并且可以正確評估數字運算。
將時間文本字串轉換為整數以進行條件數值運算的簡單方法是什么?
迄今為止的嘗試:
Time#(SubField(stationTime,'-',1),'hh:mm:ss') as openingTimeTest
這似乎將所有openingTime
欄位都變為-
(null)
Num(Sum(SubField(stationTime,'-',1) tempRecordingInterval)) as openingTimeRecordingInterval
在哪里SET tempRecordingInterval=2;
Keepchar([initialTempTime],'0123456789.') as [initialTempTimeNum]
uj5u.com熱心網友回復:
考慮下面的腳本。(為了清楚起見,我將它分成多個步驟/加載)
RawData:
Load
// convert to time
Time(Time#( openingTime, 'h:mm:ss')) as openingTime,
Time(Time#( closingTime, 'h:mm:ss')) as closingTime
;
Load
// "convert" to time looking string
// 6AM will be 6:00:00
// 6PM will be 18:00:00
if( index(openingTime, 'AM') > 0, KeepChar(openingTime, '01234567890'),
KeepChar(openingTime, '01234567890') 12) & ':00:00' as openingTime,
if( index(closingTime, 'AM') > 0, KeepChar(closingTime, '01234567890'),
KeepChar(closingTime, '01234567890') 12) & ':00:00' as closingTime
;
Load
// split the station time
SubField(stationTime, '-', 1) as openingTime,
SubField(stationTime, '-', 2) as closingTime
;
Load * Inline [
stationTime
6AM-10AM
6PM-10PM
];
結果表將如下所示:
(顯示基于SET TimeFormat
腳本開頭的變數值)
資料Time
格式化后,我們可以像這樣添加/減去小時數:
= time( openingTime 2 / 24 ) // add two hours to openingTime field
= time( openingTime - 2 / 24 ) // subtract two hours to openingTime field
如果我們在openingTime
兩個小時內選擇“06:00:00”值,加法將給我們:
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/473896.html