set current date

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
ahmed7
User
Posts: 97

set current date

Post 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


darkdragon
User
Posts: 148

Post 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?


ahmed7
User
Posts: 97

Post by ahmed7 »

Days , but this period will be between two fields , one set as current date and the other is normal selected date/


darkdragon
User
Posts: 148

Post by darkdragon »

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 ...


ahmed7
User
Posts: 97

Post by ahmed7 »

actually I need to put current date as I said before


MichaelG
User
Posts: 1095

Post 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


Post Reply