We are currently updating the OP Help Center content for the release of OP 14.19 or OP 19. OP 19 is a member of the certified OP 14 family of products (official version is 14.19.1), which you may see in your software (such as in Help > About) and in the Help Center tabs labeled 14.19. You may also notice that the version number in content and videos may not match the version of your software, and some procedural content may not match the workflow in your software. We appreciate your patience and understanding as we make these enhancements.

SQL: Ages and CPTs of Patients Seen between Dates


This report shows patient chart number, first & last name, date of service, DOB, age, and billed CPT code.

A sample image of this SQL report run in the Database Viewer is shown below:


  • Age is the age on the date of service, not necessarily the patient’s current age.
  • It does not include voided CPT codes.


To highlight and copy the code below to your clipboard, simply click the Copy button.

select patno, date1, birthdat,
floor(datediff(month, dateadd(day,-extract(day from birthdat)+1,birthdat), dateadd(day,-extract (day from birthdat)+1,date1))/12) as age_on_dos, cptcode
 from  register 
inner join archive_transactions on archive_transactions.patno  = register.patno 
where date1 between :start_date and :end_date
 and archive_flag = 1 and cptcode not in ('1','2','3','4')