Get first day of year

tandzytandzy Member Posts: 3
Hello everyone, I am new here so sorry if my question sounds a little bit stupid :) But cant find anywhere this what I need.

So, I want my user to enter year on Request Page like just 2015.
Then I must in my code somehow get the first day of that year and the last day of that year.
It would be like this - user enter 2015 and I want to get 01.01.2015 and 31.12.2015.

Thanks in advance for your replies,
](*,)

Comments

  • krikikriki Member, Moderator Posts: 9,112
    Check out the function DMY2DATE.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • tandzytandzy Member Posts: 3
    Kriki, thank you for your reply.

    I know what function DMY2DATE is used for ( at least I think I know). I use it when I want to get day, month or year from specific date like
    Day := DATE2DMY(SomeDate,1);
    Month := DATE2DMY(SomeDate,2);
    Year := DATE2DMY(SomeDate,3);

    But I think I need the oposite of that - I say year and for output I need date of first day in that year like I said in previous post
    From 2015 i want to get 01.01.2015
    and 31.12.2015.

    Thank youuuu very much.
    :shock: :shock: :shock:
  • krikikriki Member, Moderator Posts: 9,112
    The DMY2DATE is the opposite function of DATE2DMY. So it is the function you need.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    ... or use the CALCDATE function, based on your date:
    FirstDayOfYear := CALCDATE( '<-CY>', YourDate );
    LastDayOfYear := CALCDATE( '<CY>', YourDate );
    
    Jan Veenendaal
  • DenSterDenSter Member Posts: 8,307
    ... or use the CALCDATE function, based on your date:
    FirstDayOfYear := CALCDATE( '<-CY>', YourDate );
    LastDayOfYear := CALCDATE( '<CY>', YourDate );
    
    The problem with this is that the request page only asks for a year, so you'd have to create a date out of the year before you can use CALCDATE.

    If you only have an integer for the year, then DMY2DATE is what you're looking for
Sign In or Register to comment.