We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DateRange Predefined set of date ranges

Can't see any example code for DateRange Predefined set of date ranges on this page https://www.syncfusion.com/blazor-components/blazor-daterangepicker - is there any documentation available anywhere?

5 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team November 7, 2019 09:52 AM UTC

Hi Alex,

Good day to you.

Yes, we have online documentation to configuring the predefined date range. 
Please refer the below documentation link for more information: https://ej2.syncfusion.com/blazor/documentation/daterangepicker/data-binding/ 

AW Alex Whittle November 7, 2019 09:54 AM UTC


How do I do this - I can't see the example code for this in any of the demos?

NP Narayanasamy Panneer Selvam Syncfusion Team November 8, 2019 10:31 AM UTC

Good day to you.

We have prepared a sample as per your requirement using DateRangePicker’s Preset property. Refer the given code example, 
@using Syncfusion.EJ2.Blazor.Calendars; 
            <DateRangePickerPreset Label="This Week" Start="@weekStart" End="@weekEnd"></DateRangePickerPreset> 
            <DateRangePickerPreset Label="This Month" Start="@monthStart" End="@monthEnd"></DateRangePickerPreset> 
            <DateRangePickerPreset Label="Last Month" Start="@lastMonthStart" End="@lastMonthEnd"></DateRangePickerPreset> 
            <DateRangePickerPreset Label="Last Year" Start="@lastYearStart" End="@lastYearEnd"></DateRangePickerPreset>         
    static DateTime lastMonth = DateTime.Now.AddMonths(-1); 
    //static double days = (double)DateTime.Now.DayOfWeek; 
    static DateTime weekStart = new DateTime().AddDays(4); 
    static DateTime weekEnd = weekStart.AddDays(6); 
    static DateTime monthStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); 
    static DateTime monthEnd = monthEnd.AddMonths(1).AddDays(-1); 
    static DateTime lastMonthStart = new DateTime(lastMonth.Year, lastMonth.Month, 1); 
    DateTime lastMonthEnd = lastMonthStart.AddMonths(1).AddDays(-1); 
    DateTime lastYearStart = new DateTime(DateTime.Now.Year - 1, 1, 1); 
    DateTime lastYearEnd = new DateTime(DateTime.Now.Year - 1, 12, 31); 

We have prepared a simple demo sample for your reference,
We will include this demo sample in our blazor sample browser, it will be available with our Beta release. 

Narayanasamy P.

VD Varun D November 24, 2020 07:07 AM UTC

Hi sir, What is FJ2 in Syncfusion.EJ2.Blazor.Calendars and why are you adding Ejs as a prefix in <EjsDateRangePicker> ? The solution you had referred  has dependency to Syncfusion.Ej2.Blazor under packages. But mine refers to  Syncfusion.Blazor. It's quite frustrating!

SP Sureshkumar P Syncfusion Team November 25, 2020 12:04 PM UTC

Hi Varun, 
Thanks for your update.  
The mentioned Syncfusion.EJ2.Blazor NuGet package name is our previous version from version, it will be Syncfusion.Blazor. Other Blazor packages will also have the same name changes. Also, In the previous version, the component names are prefixed with Ejs (example: EjsGrid, EjsChart) which has been changed to the prefix Sf (example: SfGrid, SfChart). 
Sureshkumar P 

Live Chat Icon For mobile
Up arrow icon