水晶报告 - 上个月的最后一天

时间:2015-10-22 13:44:48

标签: sql crystal-reports

我在一个程序中得到了这个公式,但它给了我本月的第一个。我需要获取上个月的最后一天,因此报告会在当月的第3天运行,我们只需要上个月的数据。

ToNumber(ToText(Year(CurrentDate), 0, "") + ToText(Month(CurrentDate), "00") + '01')

4 个答案:

答案 0 :(得分:2)

你可以使用

{datefield} in lastfullmonth

或者如果你只需要最后一天

date(year(currentdate),month(currentdate),1)-1

答案 1 :(得分:0)

这能满足您的需求吗?

struct Den_t
{
    int day, month, year;
}; 

int main()
{
        struct Den_t* Datum = new struct Den_t;
        struct Den_t* Dnes = new struct Den_t;

    time_t theTime = time(NULL);
    struct tm aTime;
    localtime_s(&aTime, &theTime);

    Dnes->day = aTime.tm_mday;
    Dnes->month = aTime.tm_mon + 1;
    Dnes->year = aTime.tm_yday + 1900;

    cin >> Datum->day >> Datum->month >> Datum->year;
    if (Dnes->year - Datum->year >= 18 )
        cout << "full aged " << endl;
    else
        cout << "not full aged " << endl;
    system("PAUSE");
    return 0;
}

答案 2 :(得分:0)

使用CDLASTDAYOFMONTH功能以及通常的月/日期功能

CDLASTDAYOFMONTH(Month(DateAdd ("m", -1, CurrentDate))); 

答案 3 :(得分:0)

这应该有用。

maximum(Lastfullmonth)
相关问题