在Crystal Report,我想格式化日期(小于10的加上0),但以下代码不行的?请各位指示。谢谢。:)

miaomiaoga 2005-10-25 05:45:58
DateVar Invoice_Date = cdate(cStr({Company_Invoice_View.Invoice_Date}));
StringVar strYear = "";
StringVar strMonth = "";
StringVar strDay = "";
StringVar strYMD = "";

strYear = cstr(Year(Invoice_Date));

strMonth = cstr(Month(Invoice_Date));
if cdbl(strMonth) < 10 then
strMonth = cstr("0") + cstr(strMonth);

strDay = cstr(Day(Invoice_Date));
if cdbl(strDay) < 10 then
strDay = cstr("0") + cstr(strDay);

strYMD = strYear + "-" + strMonth + "-" + strDay;
...全文
104 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
miaomiaoga 2005-10-26
  • 打赏
  • 举报
回复
呀。。。果然是。。。。可以格式化的。。。我晕!我还废了时间在这上面。。我蠢屎了。。
xwdd129 2005-10-26
  • 打赏
  • 举报
回复
这需要写公式吗? 可以直接格式化成你需要的样式阿
yydwtbml 2005-10-25
  • 打赏
  • 举报
回复
试试这个,不过是VB的
Public Function GetDate() As String
Dim strY, strM, strD, strDate As String
strY = System.DateTime.Now.Year
strM = System.DateTime.Now.Month
strD = System.DateTime.Now.Day
If Len(strM) = 1 Then
strM = "0" & strM
End If
If Len(strD) = 1 Then
strD = "0" & strD
End If
strDate = strY & "-" & strM & "-" & strD
Return strDate
End Function

4,818

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧