Last day of each month and first day of each month (Delphi)

Source: Internet
Author: User
Procedure getmonthday (const adate: tdatetime;
VaR amonthfirst, amonthlast: tdatetime );
VaR
Year, month, day: word;
Begin
Decodedate (adate, year, month, day );
Amonthfirst: = encodedate (year, month, 1 );
If month + 1> 12 then
Amonthlast: = encodedate (Year + 1, 1, 1)-1
Else
Amonthlast: = encodedate (year, month + 1, 1)-1
End;

Procedure getmonthday (const adate: tdatetime;
VaR amonthfirst, amonthlast: tdatetime );
VaR
Year, month, day: word;
Begin
Decodedate (adate, year, month, day );
Amonthfirst: = encodedate (year, month, 1 );
Amonthlast: = encodedate (year, Inc (month), 1)-1
End;

First day of each month: encodedate (year, month, 1 );
Last day of each month: encodedate (year, Inc (month), 1)-1;

Day 1: strtodate ('2017-01-01 ')
Last day: strtodate ('2017-02-01 ')-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.