Crystal reports 如何添加13分钟';时间域中的时间(非日期时间域)水晶报告
我尝试使用Crystal reports 如何添加13分钟';时间域中的时间(非日期时间域)水晶报告,crystal-reports,crystal-reports-2008,crystal-reports-2010,crystal-reports-xi,crystal-reports-8.5,Crystal Reports,Crystal Reports 2008,Crystal Reports 2010,Crystal Reports Xi,Crystal Reports 8.5,我尝试使用Dateadd('n',13,{fieldname}) 但它抛出一个错误,该错误不是有效的日期时间字段,因为它是时间字段。 有没有办法将其转换为datetime并添加值,然后将其还原为time字段 谢谢。试试这个公式: DateAdd('n',13,DateTime(CurrentDate,{fieldname})) DateTime(date,time)函数将创建一个在DateAdd()函数中工作的DateTime值。但是,这仅在{fieldname}是时间数据类型时才起作用 如果{
Dateadd('n',13,{fieldname})
但它抛出一个错误,该错误不是有效的日期时间字段,因为它是时间字段。
有没有办法将其转换为datetime并添加值,然后将其还原为time字段
谢谢。试试这个公式:
DateAdd('n',13,DateTime(CurrentDate,{fieldname}))
DateTime(date,time)
函数将创建一个在DateAdd()函数中工作的DateTime值。但是,这仅在{fieldname}
是时间数据类型时才起作用
如果{fieldname}
是一个字符串,则需要首先使用Time(Time)
函数将其转换为时间数据类型
我上面建议的公式将把您的时间值附加到今天的日期。然后需要格式化它返回的日期时间值,以便只显示时间值。这可以通过右键单击crystal报告中的字段,然后单击“格式字段”并在“日期和时间”选项卡上设置样式来完成。效果非常好!!谢谢,有没有办法将其转换回字符串,例如:我将格式更改为6:00或5:69至600或569。要将其转换为字符串,您可以使用ToText()
函数或CStr()
函数。两者都可以接受2个参数以提供格式选项。即ToText({DateTimeField},“dd-MM-yyyy hh:MM:ss”)
或CStr({DateTimeField},“dd-MM-yyyy hh:MM:ss”)
。这两个函数的工作原理相同,但在Crystal语法和Basic语法中的支持方式不同。