QuickBase API Cookbook v3 - Recipe #66
Format a duration value retrieved from QuickBase
duration format
The QuickBaseAPI returns duration field values in milliseconds, but you need to display the value as Days, Hours, or Minutes.
require 'QuickBaseClient'

# change "username" "password" to your QuickBase username and password
qbc =  QuickBase::Client.new("username","password")

# read and format the "duration" field from all the records in a table
qbc.iterateRecords("dbiddbid",["duration"]){|rec|
  rawValue = rec['duration']
  days = qbc.formatDuration(rawValue.dup,"days")
  hours  = qbc.formatDuration(rawValue.dup,"hours")
  minutes  = qbc.formatDuration(rawValue.dup,"minutes")
  printf("Raw value: %-15s Days: %-10s Hours: %-10s Minutes: %-10s\n", rec['duration'], days, hours, minutes)
}

=begin

Sample output from this script:

Raw value: 172800000       Days: 2          Hours: 48         Minutes: 2880
Raw value: 285120000       Days: 3          Hours: 79         Minutes: 4752
Raw value: 2160000000      Days: 25         Hours: 600        Minutes: 36000
Raw value: 10658304000     Days: 123        Hours: 2960       Minutes: 177638
Raw value: 37152000        Days: 0          Hours: 10         Minutes: 619
Raw value: 86400000        Days: 1          Hours: 24         Minutes: 1440

=end
formatDuration.rb
Created on Feb. 24, 2008 at  2:51 PM (PST). Last updated by Quick Base on Feb. 24, 2008 at  2:58 PM (PST). Owned by Quick Base.
Quick Base
Quick Base
Show fields from Show fields from Show fields from a related table
Report Name *
Description
Reports and Charts Panel
Each table has a panel listing its reports and charts, organized in groups.
Please wait while your new report is saved...
Field label
Column heading override
Justification
What does auto mean?
Fields in:

Fields to Extract:

Name for the new table:
Items in the new table are called:

When you bring additional fields into a conversion, Quickbase often finds inconsistencies. For example, say you're converting your Companies column into its own table. One company, Acme Corporation, has offices in New York, Dallas and Portland. So, when you add the City column to the conversion, Quickbase finds three different locations for Acme. A single value in the column you're converting can only match one value in any additional field. Quickbase needs you to clean up the extra cities before it can create your new table. To do so, you have one of two choices:

  • If you want to create three separate Acme records (Acme-New York, Acme-Dallas and Acme-Portland) click the Conform link at the top of the column.
  • If the dissimilar entries are mistakes (say Acme only has one office in New York and the other locations are data-entry errors) go back into your table and correct the inconsistencies—in this case, changing all locations to New York. Then try the conversion again.

Read more about converting a column into a table.

We're glad you're interested in doing more with Quickbase!

Now we need to make you official before you share apps or manage your account.

Verifying your email lets you share Quickbase with others in your company.

Your work email
Your company