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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateRange Predefined set of date ranges

Thread ID:

Created:

Updated:

Platform:

Replies:

148871 Nov 6,2019 05:54 PM UTC Nov 8,2019 10:31 AM UTC Blazor 3
loading
Tags: DateRangePicker
Alex Whittle
Asked On November 6, 2019 05:54 PM UTC

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?

Narayanasamy Panneer Selvam [Syncfusion]
Replied On 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/ 
 


Alex Whittle
Replied On November 7, 2019 09:54 AM UTC

Hi,

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



Narayanasamy Panneer Selvam [Syncfusion]
Replied On 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; 
 
    <EjsDateRangePicker> 
        <DateRangePickerPresets> 
            <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>         
          </DateRangePickerPresets> 
    </EjsDateRangePicker> 
 
  
@code{ 
 
    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. 

Regards,
Narayanasamy P.
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon