Delphi Issameday, Istoday Function-judge is not the same day, judge is not today

Source: Internet
Author: User

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
  procedure FormCreate(Sender: TObject);
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

uses DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
var
 t1,t2,t3,t4: TDateTime;
 b: Boolean;
begin
 t1 := StrToDateTime('2009-1-21');
 t2 := StrToDateTime('2009-1-21');
 t3 := StrToDateTime('2009-5-21');
 t4 := Now;

 {判断是不是同一天}
 b := IsSameDay(t1, t2); //True
 b := IsSameDay(t1, t3); //False

 {判断给定时间和当前时间是不是同一天}
 b := IsToday(t1); //False
 b := IsToDay(t4); //True

// ShowMessage(BoolToStr(b, True));
end;

end.

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.