LISTSERV Maestro 11.1-3 Help Table Of Contents

Calculation Formulas

Back to Calculation Formulas Overview
Back to Functions Overview


Function "ToMillis"

ToMillis(datetext, formatpattern [, localename | langcode, countrycode])

Function: Returns the numerical value representing the date/time as parsed from the "datetext" argument, where the numerical value specifies the date/time in milliseconds since "Jan. 1st 1970, 00:00:00 GMT" (which can, for example, then be compared to the output of the functions CurrentMillis, SubscribeTimeMillis and LastMidnightMillis, or be used as input to ToDateText).

Generates a runtime error if there is a parse error. If you are unsure if a certain "datetext" and "formatpattern" can be parsed without an error, and you want to avoid this error, then use the companion function IsDate to first check if the arguments can be parsed at all, together with the function If (see the examples below.)

The format that is used to parse the given date/time text string is specified with the given format argument. Please see here for details about how to write the format pattern.

Note: For formatting purposes, LISTSERV Maestro will by default use the U.S. locale and the time zone of the server where the LUI component is running. Therefore, locale specific texts, like weekday names, names of months, and so on, will be formatted using the U.S. locale. Similarly, times will be formatted using the server's time zone.

If you want to specify a different locale, you can do so with the optional parameter "localename" to choose a predefined locale or with the optional parameters "langcode" and "countrycode" to specify your own locale. See here for details.

If you want to specify the time as relative to a different time zone, you can include a time zone value in the date/time text.

Return-Type: Number

Arguments:
datetext - Type Text: The date/time text string to parse. Must contain the desired date/time in a textual format that can be parsed by applying the given format pattern.
formatpattern - Type Text: specifies the format pattern to use to parse the "datetext". Please see here for details about this format pattern.
 
(The following arguments are optional. Either you supply no further argument at all or you supply only the following argument)
localename - Type Text: A name of a predefined locale. See here for a list of available locale names. If specified, any locale specific text in "datetext" will be expected according to this locale.
 
(Or you supply both the following two Arguments)
langcode - Type Text: A lowercase two-letter ISO-639 language code specifying the language for the locale. For example, see here http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt for one list of the ISO-639 language codes.
countrycode - Type "Text": An uppercase two-letter ISO-3166 country code specifying the country for the locale. For example, see here http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm for one list of the ISO-3316 country codes.
If "langcode" and "countrycode" are specified, they are used to create a locale for the given language and country, and any locale specific text in "datetext" will be expected according to this locale.

Examples:
ToMillis("February 22. 2004", "MMMM dd. yyyy")
(parses the given date using the default U.S. locale)
 
ToMillis("Februar 22. 2004", "MMMM dd. yyyy", "Germany")
(parses the given date using the pre-defined locale for Germany)
 
ToMillis("februari 22. 2004", "MMMM dd. yyyy", "de", "AT")
(parses the given date using a custom locale for language "de" =German and country "AT" =Austria)
 
If(IsDate(&FIELD;, "MMMM dd. yyyy"), ToMillis(&FIELD;, "MMMM dd. yyyy"), 0)
(checks if FIELD contains a date that can be parsed with the given pattern and the default U.S. locale, and if so, returns the numerical representation of this date, otherwise returns the default "zero (0)".)

© 2002-2023 L-Soft Sweden AB. All rights reserved.