Date
Date-func
Description
The date function returns the Julian-day value which Origin uses internally to represent dates.
See this note.
Syntax
double date(string MM/dd/yy HH:mm:ss.##[, string format])
double date(int yy,int MM,int dd)
Parameter
MM/dd/yy HH:mm:ss.## or yy,MM,dd
- The date you want to get the Julian-day value, yy as year, MM as month, dd as date, HH as hour, mm as minute, ss as second. Time arguments (HH:mm:ss.##) is optional.
- Note that the conversion is based only on the year, month and day values. Day names will be validated independently, but not checked against calendar. Please consider the following scripts:
jdn1 = date(Thu Sep 24 09,"ddd MMM dd yy"); // OK
jdn2 = date(Fri Sep 24 09,"ddd MMM dd yy"); // OK even though not a Friday
jdn3 = date(XXX Sep 24 09,"ddd MMM dd yy"); // Returns missing value
- The date function will accept time arguments of fractional seconds, such as:
n = date(11/3/1999 08:07:06.54321);
- However, due to the small magnitude of fractions of a second, the large magnitude of the Julian date value for dates in the 20th century, and the limited (8 byte) memory for numbers, round-off errors limit the entry of fractional seconds to about 4/100000 of a second (40 microseconds).
format
- Optional argument. Specify the format of the input date string. Without the format argument, format is determined by Windows regional settings. The format argument can be used to override those settings. For example, if your Windows Region and Language is set to English(United States), you can run the following scripts to see the difference:
jdn1 = date(3/5/2014); //should return 2456721
jdn2 = date(3/5/2014,"dd/MM/yyyy"); //should return 2456780
- A Note on the format argument
- The date function can take a ternative optional argument to determine the format used by the date portion of the first argument:
-
format |
Results in... |
1 |
MM/dd/yyyy |
2 |
dd/MM/yyyy |
3 |
yyyy/MM/dd |
- If format is not specified, the format defaults to MM/dd/yyyy (value of argument = 1).
- For example, the scripts in the previous section can also be:
jdn1 = date(3/5/14); //should return 2456721
jdn2 = date(3/5/14,2); //should return 2456780
Return
Returns the Julian-day value of the input date. The integer part of the returned value is the number of Julian days and the fractional part is the fraction of a 24 hour day.
Example
The following script assigns a date-time value of January 28, 1986 at 1:13PM to cell 1 of column 1.
wcol(1)[1] = date(28/1/1986 13:13, 2);
The following script sets the third cell of the second column to 5/7/99 if the column Format is set to Date.
col(2)[3] = date(5/7/99);
|