Is there a way to make a table trigger that sends an email once a date attribute get 30 days from the date listed? e.g. 07/31/2020 is listed in the table and when it gets to 07/01/2020 in real life, an email is sent out to notify someone. it would be a 30 day in advance notification.
Thanks
You can make an SQL Job, which will executed on daily basis and send db email once it get date difference (datediff(D, getdate(),'2020-07-31) equals to 30 OR change in the table to trigger
Related
It's a number of years since I have used Access and I'm creating an asset database using Access 2016 and need to send an automated email with a report that will show assets that are due to be refreshed in the next year, six months, 3 months, then 2 months then 1 month. The report does have a date field called refresh date.
I have see details on how to send an email from access but I cannot find how to automatically run the report and for it to search by the date field?
Any help would be appreciated
Thanks
One solution would be to launch your access application from the Task Scheduler. That way you can setup in detail when to launch the application. Then within the application you can produce the report based on the current date.
You need to:
-Setup Task Scheduler to launch the application at the desired times.
-Set macro Autorun to launch a VBA script.
-The VBA script checks if the given conditions are true. If so it produces the report, exports it as a PDF file and makes the email with the file file.
Please specify your question more in case you need further help on "and for it to search by the date field?".
You could set a timer on the form that checks if Now() = date on the form + X number of days (30, 60, 90, 180, 365) and if it hits one of them it sends the appropriate email.
If the DB is open all the time have it run once a day (timer interval of 86400000 ms).
If it is going to be open but not all the time have the interval set to a lower amount.
I am using mysql and flask to develop a time-cards management system (which is basically an attendance taking software), in which I need to check the time a user is logged in and logged out and the interval of the session to calculate his working time and I should be able to update the database as a leave if he didn't login the whole day. And I need to store the data monthly-wise so that we can calculate the salary of the employee depending on his working hours and leaves in that month.
Can someone please help me how to:
Design my database such that we can store the monthly information of all
employees efficiently (like should i create a table for each month or some
other way?)
How to check the time of login and logout and the length of session of a
user?
How to check whether a user is logged in at least once in a day or not?
Thanks in advance.
Record the start and end time of each work period in a table.
create table time_record (
time_record_id int not null auto_increment primary key,
start_time datetime not null,
end_time datetime not null,
person_id int not null references person(person_id)
);
Then you can report on daily or monthly activity for each user with some simple queries. For instance, to roll up to a daily summary, you can join a set of calendar days against the time records.
I have a microservice and I use REST methods such as GET PUT POST, for this issue lets take an example POST !
I want to add a record to one table, but I need to only add two values and the remaining two are id and date. ID is auto increment and have used Sequence Generator, hence working even if I do not give an ID as input.
I would like to do the same for Date but would like to not input date plus make sure the date set for that record is the SYS Date in the Oracle DB, I have made Date variable default as SYSDate in DB but its still not taking in a null value as its not null. How do I implement this ?
Help is truly appreciated !
How can I start charging a user the user immediately for a PayPal billing agreement?
Here's what I've got so far.
Create a Billing Plan (POST .../payments/billing-plans/)
Make it active (PATCH .../payments/billing-plans/)
Create a Billing Aggreement (POST .../payments/billing-agreements/)
Send user to approval_url, user approves, redirected to return url
Execute agreement (POST .../payments/billing-agreements//agreement-execute)
This all seems to work, but I want to charge the user right now and every month in the future. If I set start_date to now in step 3 I get an error, it must be in the future. If I set it in the future the user is not charged.
Do I need to 'Set outstanding agreement amounts' then 'Bill outstanding agreement amounts' for the initial payment?
Also, what about monthly payments, do they require some action or do they just happen as specified in the Billing Plan?
Update
I'm testing this around 2014-09-16T20:06:30+0000
If I send start_date as the current UTC time it get an error at step 2 telling me it must be in the future.
If I send the current date +30 secs or +2 hours I get through to step 5 which returns a 400 response: UNKNOWN_ERROR "An unknown error has occurred"
If I send the current date +4 hours it all works. The current UTC time is 8pm so adding 4 hours means the start_date is tomorrow.
Does this mean I can't charge the user today? Does the start_date have to be in next day or even the next business day?
I've talked to a PayPal rep and found that start_date must be tomorrow or later. They are going to add this to the docs.
If you want to start monthly billing immediately you might be able to do it by setting the start date to be in one months time and charging a setup fee to cover the first month. I haven't tested this as it's not what I want.
First payment for agreements will be billed right on specified start_date. The subsequent amounts are also taken automatically by PP. You need to work with the BillOutstandingAmount calls only if PP failed to pick the payment on the renewal date.
The problem I faced when developing with their RestAPI was specifying a wrong timezone. Maybe this is the same for you. Make sure the proper timezone is specified in your start_date (with all dates given to PP in fact)
Dates should be in this format: yyyy-MM-ddTHH:mm:ssZ
ex. start_date = 2014-09-16T09:20:00-0400
IF you want to make sure Paypal accepts the date as being valid, just add a few seconds to it.
Let's say you are in Java, you can do something like:
private String getPaypalDate()
{
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
// Add 30 seconds to make sure Paypal accept the agreement date
Date rightNow = new Date(new Date().getTime() + 30000);
return df.format(rightNow);
}
I used this date format working.
$time = time();
$startDate = date('Y-m-d\\TH:i:s\\Z', $time);
I can't replicate, actually. I stumbled on this thread when getting the error due to setting it to moment.now(). But setting it to even 5 seconds in the future works a-ok. I'm using JavaScript, "start_date": moment().add({seconds:5}).format() and that checks out fine. Moment.js will set TZ to UTC when formatting as such, so it's gotta be a timezone thing on your end?
It looks like the payments just process based on the date being before or after 07:00 UTC of the current date.
For example. The current date time is 2017-05-04T04:50:00.00Z I set my start date to be the current UTC date time plus 30 seconds. Because the agreement date is set to a value greater then the current date time the API doesn't throw an error, but it DOESN'T set your time to be what you specified. Instead it sets it to 2017-05-04T07:00:00Z.
Now, if you have the same date time of 2017-05-04T04:50:00.00Z and instead of adding 30 seconds you add 24hrs you'd think that your time would then be set to be 2017-05-05T04:50:00.00Z. But no, the time will be set to 2017-05-05T07:00:00Z.
So it seems like these just process everyday at 07:00 UTC and you can't specify anything but the date.
Upon logging into their accounts, each user has their login date and time stored to the database. What I was looking to do however is figure out the amount of days (or preferably convert into months if greater than a month) so that if a user views their profile they can see how active the band are. Also, this could benefit me in terms of keeping active profiles top of the agenda for content on the site so that it doesn't become stale from inactive users content filling up main page content.
I'm using ColdFusion so i'd be looking for a way to find for example how many days ago #lastLogin# was from #now()#. So say if the date of the last login was 23/04/2013 and todays date is 29/04/2013 it would read "Last Active, 1 day ago." However if the last login was 23/03/2013, it would read "Last Active, 1 month ago".
Anybody know how to do this? Thanks.
P.S I currently have no code from testing this as I have no idea where to start in terms of achieving this.
Use DateDiff
<cfset days = dateDiff("d", LoginDateVariable, now()) />
It's as simple as that.
P.S I currently have no code from testing this as I have no idea where
to start in terms of achieving this.
This doesn't answer your direct question but to help you know where to get started, I would strongly suggest reviewing the built in ColdFusion functions and tags that are available to you.
Tags
Tags by function
Functions
Functions by category
Also, Google searches usually land you at the docs, just add "coldfusion" to your search string. Searching google for coldfusion date functions yields very helpful answers, the first of which are a list of all ColdFusion date functions.
Dale's answer is spot on. But I would also suggest returning it as a variable with your query. Let the SQL server do the work. It's very efficient for those types of calculations. Not that CF can't do them well, too. But it's probably more appropriate for SQL to do that lifting. Especially if you're already returning the lastLogin date.
It would be similar to the CF solution:
SELECT ...., lastLogin, DATEDIFF(d, lastLogin, GETDATE()) AS LastLoginDays
FROM ....
WHERE ....
That would give you the number of days. You'd have to decide how you wanted to define a month if you wanted to break it out by month/day. That would get a bit more complex. You could write a SQL function that could be run on both dates and give you an accurate count of days/months/years since last login.
One other thing to keep in mind: Where are the dates being generated? When you insert loginDate into the database, are you doing a now() in CF before you insert it or are you doing a getDate() in SQL when you insert it? Again, I would let the database do your date logic, but you'd want to compare the two dates from the same source. For instance, if your loginDate was a database getDate() then you may not want to compare that to a CF now(). One goes by the datetime of the SQL server and the other goes by the datetime of the CF server. They could be different.