SQL Statement Help
I am building scheduled tickets using a second queue that opens the ticket on our primary queue. (I found the process here) But we all know how scheduling works using custom ticket rules. I am wondering if there is way to write a SQL statement that will create the ticket quarterly, yearly, every so many days, and last business day of of the month. I have little knowledge of SQL so any help would be appreciative!
Thanks!
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
chucksteel
6 years ago
You will need to look into the MySQL datetime functions:
Using those functions, and some help from Google/StackOverflow you can figure out if today is the first day of the quarter. That allows you to add something like:
DATE(NOW()) = (
SELECT MAKEDATE(YEAR(CURDATE()), 1) + INTERVAL QUARTER(CURDATE()) QUARTER
- INTERVAL 1 QUARTER )
To your where clause and the ticket rule will only return results when that statement is true.
Reference: https://stackoverflow.com/questions/11884618/how-do-i-get-the-first-date-of-a-quarter-in-mysql
Comments:
-
This is great! I'm still stumped on the last business day of the month that is not a weekend day. - abratton 6 years ago
-
Did you ever figure out how to create a ticket rule to fire off the last business day of every month? Kace application really lacks big time in recurring ticket functionality. - brianpink 5 years ago
-
I came up with a test query that should run today. If it doesn't run tomorrow, I'll post it. - chucksteel 5 years ago
-
See the answer that I submitted here:
https://www.itninja.com/question/ticket-rule-last-business-day-of-every-month - chucksteel 5 years ago