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!
Please log in to answer
Posted by: chucksteel 2 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.