2013-05-07 115 views
1

我有一個計算的字段,作爲「參考號」通過合併日期和時間。但是,問題是時間格式,它顯示上午/下午,我需要使它作爲軍事時間格式或24小時格式。有沒有一個公式呢?我搜索了一些筆記本,但找不到任何東西。你可以幫我嗎?這是我的代碼:蓮花筆記:公式:24小時時間格式顯示

REM {Variable Assignment}; 
cType := RequestType; 
cDate := @Text(@Created; "D0S0"); 
cTime := @Text(@Now; "T0S1"); 

REM {Get the list of synonyms from the svType view}; 
cView := "svKeywordType"; 
clist := @DbColumn("": ""; @DbName; cView; 2); 
@If((@IsError(clist) | clist = ""); "There is no request type in this system."; clist); 

REM {Get the request type description list}; 
cDesclist := @Left(clist; " | "); 

REM {Get the request type synonym list}; 
cSynonymlist := @Right(clist; " | "); 

REM {Check the position of the request type from the list}; 
cPos := @Member(cType; cDesclist); 

REM {Given the position, get the request type description}; 
cSynonym := @Subset(@Subset(cSynonymlist; cPos); -1); 

REM {Get the mm value}; 
cMonth := @Left(cDate; "/"); 
REM {Get the dd value}; 
cDay := @Left(@Right(cDate; "/"); "/"); 
REM {Get the yyyy value}; 
cYear := @Right(@Right(cDate; "/"); "/"); 
cHour := @Left(cTime; ":"); 
cMinute := @Left(@Right(cTime; ":"); ":"); 
cSecond := @Right(@Right(cTime; ":"); ":"); 

cdateToday := @Text(@Today; "D0S0"); 
ctimeToday := @Text(@Now; "T0S1"); 

cRef := cSynonym + "-" + cMonth + cDay + cYear + "-" + cHour + cMinute + cSecond; 
@If(cType = "" | @IsError(cSynonym); ""; cRef) 

編輯:順便說一下,我使用的字段是文本。嘗試使用日曆並設置爲24小時格式,但沒有奏效。

回答

3

使用@Hour - 從上午12點到下午11點,小時表示爲0到23。 代碼兩位數小時的字符串:

cHour := @Right("0" + @Text(@Hour(@Now)); 2); 

公式只會工作對英語/美國時間/數據串轉換。它不適用於德語,例如

更好地使用其他@函數太:@Year, @Month, @Day, @Minute, @Second

REM {Get the mm value}; 
cMonth := @Right("0" + @Text(@Month(@Created)); 2); 
REM {Get the dd value}; 
cDay := @Right("0" + @Text(@Day(@Created)); 2); 
REM {Get the yyyy value}; 
cYear := @Text(@Year(@Created)); 

cHour := @Right("0" + @Text(@Hour(@Now)); 2); 
cMinute := @Right("0" + @Text(@Minute(@Now)); 2); 
cSecond := @Right("0" + @Text(@Second(@Now)); 2); 
+0

感謝隊友!很好的幫助! :) – drayl 2013-05-07 07:15:19

+0

不客氣:) – 2013-05-07 07:22:09

相關問題