Skip to main content
  • API function reference
  • Who we are

Specifying date and time

Specific data and time formats are used in both specifying the time series data to be returned and in specifying the format of the returned data.

Table of contents
Select a section to jump to:

Last value

By default, requests made with the getTimeseriesValues and getGraph query functions return just the last data record.


There are three query arguments that allow a more specific period to be returned, and these may be used alone or in conjunction; they are:

  • from
  • to
  • period

Date, time and duration formats

The date, from, and to arguments are specified with a timestamp, in the format:

where:

  • yyyy is the year,
  • MM is the month,
  • dd is the day,
  • HH the hour, as 24h,
  • mm, the minute and
  • ss the second.

If the hour, minute, and second are omitted then the time 00:00:00 is applied.

The period argument is specified in terms of an integer value and key letter representing a unit of time, prefixed by P. Multiple values and keys may be strung together, but must be in descending order of duration. The recognised keys are:

  • Y = Year
  • M = Month
  • D = Day

Periods shorter than a day are additionally prefixed by T

  • H = Hour
  • M = Minute
  • S = Second

In addition, W = Week, but is mutually exclusive of the D (day) setting

Finally, period may be specified with the keyword complete, which returns the entire record.

From and To

From and to are used to define specific endpoints; if used alone, from returns data until the end of the record, and to returns data from the start of the record.

Aggregated rainfall observations at Edinburgh Royal Botanical Gardens for July 2021

Peak event on the Forth at Craigforth, station_no 4638, 2006-12-14 08:30

Period

If the period argument is specified alone it extends the default 'last value' condition to return the specified duration up to and including the last value.

For daily rainfall data the last value will be 'yesterday' at 09:00 since the data for 'today' is not complete.

Period with From or Period with To

Combining the from with period or period with to query arguments provides a neat way of returning specific periods of data without the need to determine both from and to timestamps.

Period Complete

Period complete is a request for all the data in a time series.  For most high resolution time series this will request be too many data values and will be refused.  For daily values the request can typically be used for 5 or more time series and for monthly values it will be possible to request the data for all time series of a parameter.

Setting the return date format

The format of returned timestamps is specified with dateformat argument to a query function.

Supported formats: