Page 1 of 1
Expire Date Event (v2021)
Posted: Sun Mar 12, 2023 5:24 pm
by ahmed7
Hello
I like to set value in one filed after date expire such as when current date comparation with date in field will be over so another field will changed automatically in list page without enter to edit page and change it.
Example :
end production date : 10/3/2023
current date :12/3/2023
will change production case field to "expired"
I hope to help me with this issue
thanks
Re: Expire Date Event
Posted: Mon Mar 13, 2023 1:22 am
by darkdragon
You better manage this directly in SQL. Have a job running each early morning to update the ProductionCase filed to expired.
e.g., something like:
update <table>
set ProductionCase = 'Expired'
where ProductionEndDate < getdate()
Re: Expire Date Event
Posted: Mon Mar 13, 2023 1:39 am
by ahmed7
are there any way to do in asp.net maker?
Re: Expire Date Event
Posted: Mon Mar 13, 2023 2:28 am
by darkdragon
Not possible in ANM as you want "without enter to edit page and change it"
The data should be changed independently of users accessing the application or not, according to your requirements.
Re: Expire Date Event
Posted: Mon Mar 13, 2023 2:32 am
by ahmed7
darkdragon wrote:
Not possible in ANM as you want "without enter to edit page and change
it"
The data should be changed independently of users accessing the application
or not, according to your requirements.
ok , if i do that by sql server , so i need to do this by query and execute it , and that need to execute it every time to get result , and that is the problem.
i need it be automatically .
Re: Expire Date Event
Posted: Mon Mar 13, 2023 2:38 am
by darkdragon
Is it possible to have new records with already expired production dates?
I do not get it why you want to have a continuous check?
If you run a job early on the morning (2:00AM, 3:00AM) you'll have all expired rows updated.
Is sounds like someone might add new records with already expired dates.
Re: Expire Date Event
Posted: Mon Mar 13, 2023 2:45 am
by ahmed7
darkdragon wrote:
Is it possible to have new records with already expired production dates?
I do not get it why you want to have a continuous check?
If you run a job early on the morning (2:00AM, 3:00AM) you'll have all
expired rows updated.
Is sounds like someone might add new records with already expired dates.
OK , how to make query work daily without execute it by my self?
Re: Expire Date Event
Posted: Mon Mar 13, 2023 3:14 am
by darkdragon
in this case use triggers for both insert and update action, on your table.
here is an example of a trigger which runs after insert. you need to add one after update, in the case you have an Edit form, as well, where your date might change.
CREATE TRIGGER InsertProducts
ON dbo.Products
AFTER INSERT
AS
BEGIN
UPDATE dbo.Products
SET ProductionCase = 'Expired'
WHERE ProductionEndDate < CurrentDate
FROM dbo.Products p INNER JOIN INSERTED i ON p.ID = i.ID
END
of course you need to update your column names, accordingly.
Re: Expire Date Event
Posted: Mon Mar 13, 2023 3:20 am
by ahmed7
Is (SQL Server Job Scheduler) will be useful instead of that way??
i think it will make query run in specific day and time ,
Re: Expire Date Event
Posted: Mon Mar 13, 2023 3:24 am
by darkdragon
As long as you do not allow an user to add new records with ProductionEndDate already expired, you're good to go with a job on SQL Agent (easier to manage)
Re: Expire Date Event
Posted: Mon Mar 13, 2023 4:17 am
by ahmed7
darkdragon wrote:
As long as you do not allow an user to add new records with
ProductionEndDate already expired, you're good to go with a job on SQL
Agent (easier to manage)
I allow many users to add and edit but as you said " SQL Agent (easier to manage)"