Extra field formatting
For most fields, you will most likely display exactly what is stored in Bullhorn. Dates and numbers may require additional formatting.
Dates
A date is stored in Bullhorn as a UTC datetime. This is usually unacceptable to use:
Sun Aug 01 04:00:00 UTC 2021
To make a date more acceptable we use the format() function. Using the example of the placement start date:
This will format the date as follows:
1 August 2021
There are many possible date formats but a few are provided here:
format('dd/MM/yyyy')
01/08/2021
format('d/M/yyyy')
1/8/2021
format('d MMM yyyy')
1 Aug 2021
format('M-d-yyyy')
8-1-2021
As before, we need to make sure we do not attempt to format a null date. We can protect against this with the full syntax:
This will check that there is a placement dateBegin value before attempting the formatting.
Numbers
Whole numbers will not require special formatting, but floating-point numbers (including currency values) will need special attention.
In order to fix the number of decimal places you can use the sprintf() function. This is of the format:
The .2f portion sets the number of decimal places to display. The % character is mandatory but the , is optional. Adding it will place this character as a thousands separator. A few examples will help:
sprintf('%,.2f', 123456.3456)
123,456.35
sprintf('%,.0f', 123456.3456)
123,456
sprintf('%.1f', 123456.3456)
123456.3
Again, protecting against null values is important. A correct use of sprintf() would be as follows:
Last updated
Was this helpful?