Use time portion of DateRangePicker

I have a DateRangePicker like such:

<SfDateRangePicker TValue="DateTime?" Placeholder="Select Date Range" Min="@MinDate" Max="@DateTime.Today">

            <DateRangePickerEvents TValue="DateTime?" ValueChange="@onChange" />

            <DateRangePickerPresets>

                <DateRangePickerPreset Label="Today" Start="_todayStart" End="@DateTime.Now"/>

                <DateRangePickerPreset Label="Yesterday" Start="@_yesterdayStart" End="@_yesterdayEnd"/>

                <DateRangePickerPreset Label="This Week" Start="@_weekStart" End="@_weekEnd"/>

                <DateRangePickerPreset Label="Last 7 Days" Start="@_lastSevenDaysStart" End="@DateTime.Now"/>

                <DateRangePickerPreset Label="This Month" Start="@_monthStart" End="@_monthEnd"/>

                <DateRangePickerPreset Label="Last Month" Start="@_lastMonthStart" End="@_lastMonthEnd"/>

            </DateRangePickerPresets>

        </SfDateRangePicker>


And Declarations like such:

DateTime MinDate { get; set; } = new DateTime(2022, 02, 05);

DateTime _now = DateTime.Now;

DateTime _todayStart = DateTime.Now.StartOfDay();

DateTime _yesterdayStart = DateTime.Now.AddDays(-1).StartOfDay();

DateTime _yesterdayEnd = DateTime.Now.AddDays(-1).EndOfDay();

DateTime _weekStart = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek));

DateTime _weekEnd = DateTime.Now;

DateTime _lastSevenDaysStart = DateTime.Now.AddDays(-7);

DateTime _monthStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

DateTime _monthEnd = DateTime.Now;

DateTime _lastMonthStart = DateTime.Now.AddMonths(-1);

DateTime _lastMonthEnd = DateTime.Now.AddMonths(-1).AddMonths(1).AddDays(-1);


I need to be able to get the time portion of the range I am selecting, any way I can go about this?


4 Replies 1 reply marked as answer

DY Dylan February 22, 2022 08:06 PM UTC

I also need to do this,  I have noticed the time portion is always 00:00:000


For example, if I choose TODAY.

Then my MinDate and MaxDate will be the same.

This is incorrect, cause its from start of day 00:00:000 to end of the day 23:59:99



SP Sureshkumar P Syncfusion Team February 23, 2022 02:18 PM UTC

Currently there is no support has been provided for time option in the DateRangePicker component. We have already considered this as a feature at our end and this support will be included in any one of our upcoming releases.   
   
You can track the status of this feature from the below feedback link.  
   
So, if you are providing any value it will be considered and processed the time as “12:00 AM”. If you want to get the date value along with time in start and end date value, we suggest you provide the required time value in the start and end date value as mentioned below. 
 

  
 
<SfDateRangePicker Format="dd/MM/yyyy hh:mm a" StartDate="@start" EndDate="@end">  
    <DateRangePickerEvents ValueChange="OnChange"></DateRangePickerEvents>  
</SfDateRangePicker>  
<p>DateRangePicker start date is: @start</p>  
<p>DateRangePicker end date is: @end</p>  
  
@code{  
    public DateTime? start { getset; } = new DateTime(2020, 2, 12, 9, 0, 0);  
    public DateTime? end { getset; } = new DateTime(2020, 2, 20, 14, 0, 0);  
    public void OnChange(RangeEventArgs args)  
    {  
        this.start = args.StartDate;  
        this.end = args.EndDate;  
    }  
}  
 
 
 


Marked as answer

MA Michael Aston May 14, 2024 10:42 AM UTC

Any plans to implement the time portion in the DateRangerPicker?



PK Priyanka Karthikeyan Syncfusion Team May 15, 2024 10:29 AM UTC

Hi Michael Aston,


As we mentioned earlier, we will consider the feature and implement in the certain release based on the customer request count and priority. So, we will intimate you once the road map has been prepared. You can track the status of the feature from the feedback link.

https://www.syncfusion.com/feedback/5760/   

Please upvote this feature to make this our priority. We will prioritize the features every release, based on the user demands.


Regards,

Priyanka K


Loader.
Up arrow icon