In this example, I am sharing “ How to compare or validate two dates in Angular? ” using custom validation function in Angular 7 and Angular 8 . Here, I’m validating the two dates - a start date and end date. The end date should be greater than the Start date”. Let’s see the example :- import { Component , OnInit } from '@angular/core' ; import { UserRequest } from '../model/user' ; @ Component ({ selector: 'User_Cal' , templateUrl: './usercal.component.html' , styleUrls: [ './usercal.component.css' ] }) export class UserCalComponent implements OnInit { constructor ( private EncrDecr : EncrDecrService , private http : HttpClient , private datePipe : DatePipe ) { } //model class model = new UserRequest ( null , null , null , null , null ); //Error Display error : any ={ isError: false , errorMessage: '' }; isValid