1

我有一个计算字段,通过结合日期和时间用作“参考号”。但是,问题在于时间格式,它显示 AM/PM,我需要将其设为军用时间格式或 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 小时格式,但没有用。

4

1 回答 1

4

使用@Hour- 上午 12 点到晚上 11 点的小时数表示为 0 到 23。两位数小时字符串的代码:

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

您的公式仅适用于英语/美国时间/数据字符串转换。它不适用于德语,例如

最好你也使用其他@Functions @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);
于 2013-05-07T06:03:54.960 回答