Placeholder

Customer Forum

Using dates in reporting and reporting criteria

Workbooks Support Posted: 2011-04-05 16:02

Here are two very useful pieces of information regarding reporting. 

It's essential to understand 1), and 2) is useful for presenting dates in the required format:

1) If you want to use a date as a criteria then it should be written in year-month-day order e.g. '2011-04-05'.  NOTE: You must enclose the date in single quotes otherwise it can be interpreted as 2011 minus 04 minus 05.  This is due to the underlying database of Workbooks - MySQL.  Here's what they have to say on dates - Source: MySQL reference manual - Date and Time Types: "Although MySQL tries to interpret values in several formats, dates always must be given in year-month-day order (for example, '98-09-04'), rather than in the month-day-year or day-month-year orders commonly used elsewhere (for example, '09-04-98', '04-09-98')."

 

2) You can format dates as you want them.  If you want dates to be presented as 01-Dec, you can do it.  If you prefer Apr 05 (2011), no problem.  Just use the relevant MySQL DATE_FORMAT function.  Here are some examples:

  • DATE_FORMAT(column_name, '%W %D %M %Y') outputs Tuesday 5th April 2011.
  • DATE_FORMAT(column_name, '%y%m%d') outputs 110405.

Separate the date components (the bits preceded by % symbols) with spaces, slashes and dashes as required.

 

You can do pretty much anything you want to do with dates.  You just may need to do a little documentation checking to get the desired result.