/build/static/layout/Breadcrumb_cap_w.png
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

Comments


All Answers

0
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

Answered 03/22/2018 by: chucksteel
Red Belt

  • This is great! I'm still stumped on the last business day of the month that is not a weekend day.