SecsSince1990 (Seconds Since 1990)

The SecsSince1990 function returns the number of seconds elapsed since January 1, 1990 from a date string.

Syntax

Variable=SecsSince1990 ( Source, DateOption )

Remarks

The variable in which the number of seconds is stored should be formatted as Long or as a String. If the source parameter is a date/time string and Variable is of type Long, the number of seconds since 1990 is returned. If the source parameter is a Long containing the number of seconds since 1990 and Variable is of type String, a date/time string is returned.

One of the uses for this function is to retrieve a record from a data table using the GetRecord instruction based on the time the record was stored rather than based on a record number. (See the example program.)

The SecsSince1990 function should not be nested within another function when the expected result is a string (for example, the code DateTime(1) = Left(SecsSince1990(Public.Timestamp(1,1),1),19) will not work).

Parameters

Source

The variable to be acted upon by the function. It can be a variable formatted as a String that contains a date and time, or a variable formatted as a Long that contains the number of seconds since January 1, 1990.

Type: Variable (String or Long)

DateOption

Specifies the format of the date/time string used as the source or the format of the date/time string to be returned by the function. Note: The resolution of this function is 1 second. Fractional seconds are not used during conversion from the date/time string to seconds since 1990. If they are included, the timestamp will be truncated. Right-click the parameter to display a list of options:

Option Time Stamp Element
1 “MM/dd/yyyy HH:mm:ss”
2 “ddd, dd MMM yyyy HH:mm:ss GMT”
Note: Greenwhich Mean Time if “UTC Offset” setting is set. If UTC Offset is not set, time returned will be datalogger time and “GMT” will be omitted from the string.
3 "dd/MM/yyyy HH:mm:ss"
4 "yyyy-MM-dd HH:mm:ss"
5 "yyyy-MM-dd_HH-mm-ss"
6 "yyyy-MM-dd_HH-mm-ss.ff"

Note: Fractional seconds are always reported as ".00".

Where:

  • dd = Day of Month, 01 – 31
  • ddd = day of week (Mon, Tue, Wed, etc)
  • ff = Fractional second; always reported as 00
  • HH = Hour, 00 - 23
  • MM = Month, 01- 12
  • MMM = Abbreviated name of the month (Jan, Feb, etc.)
  • mm = Minute, 00 - 59
  • ss = Seconds, 00 - 59
  • yyyy = Year, 0000 - 9999
  • GMT = Designation that time displayed is Greenwich Mean Time

Type: Constant