Calcdate issue [solved]

RoyRoy Member Posts: 3
Hello,

I'm new here and a junior programmer.

I need to filter a field from the first day of the current year (01-01-05) till the last day of the current year (31-12-05). I also need a filter of the first day of the past (01-01-04) year and the last day of the past year (31-12-04).
I'm using a calcdate but i'm stuck can anyone help me?

This is what i got so far to calculate the first day of the current year:


a := calcdate('<1Y>',workdate);

Comments

  • DenSterDenSter Member Posts: 8,307
    Add 4 date variables called CurrentYearStart, CurrentYearEnd, LastYearStart, LastYearEnd. This is in itself not necessary, but I always like to keep stuff in variables with names.
    CurrentYearStart := := DMY2DATE(1,1,DATE2DMY(workdate,3));
    LastYearStart := CALCDATE('-1Y',CurrentYearStart;
    CurrentYearEnd := CALCDATE('CY',workdate);
    LastYearEnd := CALCDATE('-1Y',CurrentYearEnd);
    
    The 'C' will give you the last date of the period. So 'CM' gives you the last day of the month, 'CQ' gives you the last day of the quarter, etcetera.

    Oh and welcome to mibuso, hopefully you will find everything you need.
  • RoyRoy Member Posts: 3
    Thanx, this works for me! :D
  • DenSterDenSter Member Posts: 8,307
Sign In or Register to comment.