DateTime format and Initial View in Radzen Blazor Studio


I am attempting to fix the current datetime. First when I try to add a new user there by default I get this view how should I change to get the current date on format (MM/dd/yyyy)

As well is there any possibility to remove the time from the datagrid dob

Date Format option in CRUD pages wizard will be available in our next update. If you do not want to recreate your CRUD pages you set the DataGrid column FormatString property to desired format and the DatePicker DateFormat property.

1 Like

To get the current date change the model initialization code in the page to new MyModel { MyDateProperty = DateTime.Now }

1 Like

That will be great to have it in the next update. I tried FormatString property before I wrote in the community but I got the result as you see it in this screenshot.

Here is the code for the datagridcolumn.
RadzenDataGridColumn TItem="Datasets.Server.Models.Test.TableName" Property="dob" Title="dob" FormatString="MM/dd/yyyy">

The FormatString property should be set to something like {0:MM/dd/yyy} as it is the argument passed to String.Format.

1 Like

Thanks a lot It solved the issue I really appreciate it!

Do you have any Idea regarding the year range how this properties work.
RadzenDatePicker DateFormat="@CurrentDate" style="display: block; width: 100%" @bind-Value="@tableName.dob" Name="dob" TabIndex="2" YearRange="@CurrentYear:@PrevYear" /
I have initialize these dates as INT
CurrentYear = DateTime.Today.Year;
PrevYears = DateTime.Today.AddYears(-100).Year;
I tried multiple case to add this range for example like @currentyear+ ":"@prevyear. But it says that component attributes do not support complex content (mixed c# and markup)

I'm trying to get the currentdate/year into these field because whenever I click to select the date it just resets

I am afraid I don't understand what you are trying to achieve.

I think that I didn't explain it well. For the first part:

  • What I'm trying to achieve is to get these values dynamic.

Because at the moment whenever I try to select the range of the year is way to big and it do not make sense that anyone can be born in 2050.


Second part was regarding the the date it shows 02/07/2023 and when I click the calendar it doesn't correspond to the date which is typed