You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Evaluates the first argument (the predicate), and returns the value of either the second or third arguments. The second and third arguments must be of the same type.
56
56
57
+
The `iif` function is equivalent to the `iff` function.
58
+
57
59
### Arguments
58
60
59
61
- predicate: An expression that evaluates to a boolean value.
|[ago()](#ago)| Subtracts the given timespan from the current UTC clock time. |
14
-
|[datetime_add()](#datetime-add)| Calculates a new datetime from a specified datepart multiplied by a specified amount, added to a specified datetime. |
15
-
|[datetime_part()](#datetime-part)| Extracts the requested date part as an integer value. |
16
-
|[datetime_diff()](#datetime-diff)| Calculates calendarian difference between two datetime values. |
17
-
|[dayofmonth()](#dayofmonth)| Returns the integer number representing the day number of the given month |
18
-
|[dayofweek()](#dayofweek)| Returns the integer number of days since the preceding Sunday, as a timespan. |
19
-
|[dayofyear()](#dayofyear)| Returns the integer number represents the day number of the given year. |
20
-
|[endofyear()](#endofyear)| Returns the end of the year containing the date |
21
-
|[getmonth()](#getmonth)| Get the month number (1-12) from a datetime. |
22
-
|[getyear()](#getyear)| Returns the year part of the `datetime` argument. |
23
-
|[hourofday()](#hourofday)| Returns the integer number representing the hour number of the given date |
24
-
|[endofday()](#endofday)| Returns the end of the day containing the date |
25
-
|[now()](#now)| Returns the current UTC clock time, optionally offset by a given timespan. |
26
-
|[endofmonth()](#endofmonth)| Returns the end of the month containing the date |
27
-
|[endofweek()](#endofweek)| Returns the end of the week containing the date. |
28
-
|[monthofyear()](#monthofyear)| Returns the integer number represents the month number of the given year. |
29
-
|[startofday()](#startofday)| Returns the start of the day containing the date |
30
-
|[startofmonth()](#startofmonth)| Returns the start of the month containing the date |
31
-
|[startofweek()](#startofweek)| Returns the start of the week containing the date |
32
-
|[startofyear()](#startofyear)| Returns the start of the year containing the date |
13
+
|[ago](#ago)| Subtracts the given timespan from the current UTC clock time. |
14
+
|[datetime_add](#datetime-add)| Calculates a new datetime from a specified datepart multiplied by a specified amount, added to a specified datetime. |
15
+
|[datetime_part](#datetime-part)| Extracts the requested date part as an integer value. |
16
+
|[datetime_diff](#datetime-diff)| Calculates calendarian difference between two datetime values. |
17
+
|[dayofmonth](#dayofmonth)| Returns the integer number representing the day number of the given month |
18
+
|[dayofweek](#dayofweek)| Returns the integer number of days since the preceding Sunday, as a timespan. |
19
+
|[dayofyear](#dayofyear)| Returns the integer number represents the day number of the given year. |
20
+
|[endofyear](#endofyear)| Returns the end of the year containing the date |
21
+
|[getmonth](#getmonth)| Get the month number (1-12) from a datetime. |
22
+
|[getyear](#getyear)| Returns the year part of the `datetime` argument. |
23
+
|[hourofday](#hourofday)| Returns the integer number representing the hour number of the given date |
24
+
|[endofday](#endofday)| Returns the end of the day containing the date |
25
+
|[now](#now)| Returns the current UTC clock time, optionally offset by a given timespan. |
26
+
|[endofmonth](#endofmonth)| Returns the end of the month containing the date |
27
+
|[endofweek](#endofweek)| Returns the end of the week containing the date. |
28
+
|[monthofyear](#monthofyear)| Returns the integer number represents the month number of the given year. |
29
+
|[startofday](#startofday)| Returns the start of the day containing the date |
30
+
|[startofmonth](#startofmonth)| Returns the start of the month containing the date |
31
+
|[startofweek](#startofweek)| Returns the start of the week containing the date |
32
+
|[startofyear](#startofyear)| Returns the start of the year containing the date |
33
+
|[unixtime_seconds_todatetime](/apl/scalar-functions/datetime-functions/unixtime-seconds-todatetime)| Converts a Unix timestamp to an APL `datetime` value. |
33
34
34
35
- We support the ISO 8601 format, which is the standard format for representing dates and times in the Gregorian calendar. [Check them out here](/apl/data-types/scalar-data-types#supported-formats)
35
36
36
-
## ago()
37
+
## ago
37
38
38
39
Subtracts the given timespan from the current UTC clock time.
39
40
@@ -75,7 +76,7 @@ ago(3d)
75
76
}
76
77
```
77
78
78
-
## datetime_add()
79
+
## datetime_add
79
80
80
81
Calculates a new datetime from a specified datepart multiplied by a specified amount, added to a specified datetime.
Returns the integer number representing the hour number of the given date
366
367
@@ -393,7 +394,7 @@ hourofday(a_date)
393
394
}
394
395
```
395
396
396
-
## endofday()
397
+
## endofday
397
398
398
399
Returns the end of the day containing the date
399
400
@@ -426,7 +427,7 @@ endofday(date)
426
427
}
427
428
```
428
429
429
-
## now()
430
+
## now
430
431
431
432
Returns the current UTC clock time, optionally offset by a given timespan. This function can be used multiple times in a statement and the clock time being referenced will be the same for all instances.
432
433
@@ -459,7 +460,7 @@ now([offset])
459
460
}
460
461
```
461
462
462
-
## endofmonth()
463
+
## endofmonth
463
464
464
465
Returns the end of the month containing the date
465
466
@@ -492,7 +493,7 @@ endofmonth(date)
492
493
}
493
494
```
494
495
495
-
## endofweek()
496
+
## endofweek
496
497
497
498
Returns the end of the week containing the date
498
499
@@ -525,7 +526,7 @@ endofweek(date)
525
526
}
526
527
```
527
528
528
-
## monthofyear()
529
+
## monthofyear
529
530
530
531
Returns the integer number represents the month number of the given year.
description: 'This page explains how to use the unixtime_seconds_todatetime function in APL.'
4
+
---
5
+
6
+
`unixtime_seconds_todatetime` converts a Unix timestamp that is expressed in whole seconds since 1970-01-01 00:00:00 UTC to an APL [datetime value](/apl/data-types/scalar-data-types).
7
+
8
+
Use the function whenever you ingest data that stores time as epoch seconds (for example, JSON logs from NGINX or metrics that follow the StatsD line protocol). Converting to `datetime` lets you bin, filter, and visualize events with the rest of your time-series data.
9
+
10
+
## For users of other query languages
11
+
12
+
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
13
+
14
+
<AccordionGroup>
15
+
<Accordiontitle="Splunk SPL users">
16
+
17
+
`unixtime_seconds_todatetime` replaces the combination of `eval strftime` / `strptime` that you normally use in Splunk. Pass the epoch value directly and APL returns a `datetime`.
Most ANSI SQL engines call this conversion with `FROM_UNIXTIME`or`TO_TIMESTAMP`. The APL version has the same single-argument signature, returns a full `datetime`, and automatically interprets the input as seconds (not milliseconds).
36
+
37
+
<CodeGroup>
38
+
39
+
```sql SQL example
40
+
SELECT TO_TIMESTAMP(epoch_seconds) AS event_time FROM events;
[Run in Playground](https://play.axiom.co/axiom-play-qf1k/query?initForm=%7B%22apl%22%3A%22%5B'sample-http-logs'%5D%20%7C%20extend%20epoch_seconds%20%3D%20toint(datetime_diff('Second'%2C%20_time%2C%20datetime(1970-01-01)))%20%7C%20extend%20datetime_standard%20%3D%20unixtime_seconds_todatetime(epoch_seconds)%20%7C%20project%20_time%2C%20epoch_seconds%2C%20datetime_standard%22%7D)
0 commit comments