水晶报表日期公式使其成为月底 [英] Crystal Report Date formula to make it the end of the month

查看:235
本文介绍了水晶报表日期公式使其成为月底的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的CR,需要一个公式,它会给我在一个日期字段的月底。
如果日期是628/2012或7/12/2012,我需要公式为月底,无论该字段显示的月份的哪一天。当然,我们知道,不是每月都在30日或31日和2月结束,有时是29日或30日。那么我可以使用什么公式来完成此操作

I'm new to CR and need a formula that would give me the end of the month a on a date field. If the Date is 628/2012 or 7/12/2012 I need the formula to to be the end of the month no matter which day of the month the field shows. Of course we know that not every month ends on the 30th or 31th and February sometimes 29th or 30th. So what formula can I use to do this

示例字段名称{table.end_date}

Example field name {table.end_date}

不胜感激。

提前感谢。

推荐答案

创建公式字段以计算月底:

Create a formula field to calculate the end of the month:

//{@EndOfMonth}
// find the first day of the month, add a month to it, then subtract a day
DateAdd("m", 1, DateTime( Year({table.dateField}), Month({table.dateField}), 1, 0,0,0 )) - 1

创建第二个将生成文本表示的公式:

Create a second formula that will generate a textual representation:

//{@TextRepresentation}
If Isnull({table.end_date}) Then
  Space(8)
Else
  ToText({@EndOfMonth}, "YYYYMMDD")

这篇关于水晶报表日期公式使其成为月底的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆