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?
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
|
<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 { get; set; } = new DateTime(2020, 2, 12, 9, 0, 0);
public DateTime? end { get; set; } = new DateTime(2020, 2, 20, 14, 0, 0);
public void OnChange(RangeEventArgs args)
{
this.start = args.StartDate;
this.end = args.EndDate;
}
} |
Any plans to implement the time portion in the DateRangerPicker?
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