Page 1 of 1
set current date
Posted: Sun May 21, 2023 5:06 pm
by ahmed7
Hello
I use V21 and need to put current date in (Date Type Field) by using edit tag (Client side event) .
I used (auto update value - currentDate()) but cannot calculate period between two dates.
I hope to get help please
Thanks
Re: set current date
Posted: Sun May 21, 2023 9:32 pm
by darkdragon
You want to calculate period between tow date, like, two different fields, right?
In this case you better do the math in c# (in Row_Insterting / Row_Updating).
The period is expressed in what? Days, Hours, Minutes?
Re: set current date
Posted: Mon May 22, 2023 1:07 am
by ahmed7
Days , but this period will be between two fields , one set as current date and the other is normal selected date/
Re: set current date
Posted: Mon May 22, 2023 3:00 am
by darkdragon
Code: Select all
DateTime dtStartDate = Convert.ToDateTime(rsnew["event_start_date"]);
DateTime dtEndDate = Convert.ToDateTime(rsnew["event_end_date"]);
TimeSpan tsDiffOfDates = dtEndDate.Subtract(dtStartDate);
int iDaysBetweenDates = diffOfDates.Days;
...
Go to learn.microsoft.com and look for TimeSpan
Struct for other examples ...
Re: set current date
Posted: Tue May 23, 2023 12:36 am
by ahmed7
actually I need to put current date as I said before
Re: set current date
Posted: Tue May 23, 2023 7:54 am
by MichaelG
If you want to calculate days between different dates in client codes, you can refer to the examples in:
https://aspnetmaker.dev/docs/#/customsc ... validate-9