This file is indexed.

/usr/share/doc/libhsqldb-java-doc/guide/builtinfunctions-chapt.html is in libhsqldb-java-doc 2.4.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter&nbsp;10.&nbsp;Built In Functions</title>
<link href="../docbook.css" type="text/css" rel="stylesheet">
<meta content="DocBook XSL-NS Stylesheets V1.76.1" name="generator">
<meta name="keywords" content="Hsqldb, HyperSQL, SQL">
<meta name="keywords" content="Hsqldb, HyperSQL, Database, JDBC, Java">
<link rel="home" href="index.html" title="HyperSQL User Guide">
<link rel="up" href="index.html" title="HyperSQL User Guide">
<link rel="prev" href="triggers-chapt.html" title="Chapter&nbsp;9.&nbsp;Triggers">
<link rel="next" href="management-chapt.html" title="Chapter&nbsp;11.&nbsp;System Management">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table summary="Navigation header" width="100%">
<tr>
<td align="left" width="30%"><a accesskey="p" href="triggers-chapt.html"><img src="../images/db/prev.png" alt="Prev"></a>&nbsp;</td><td align="center" width="40%" style="font-weight:bold;">Chapter&nbsp;10.&nbsp;Built In Functions</td><td align="right" width="30%">&nbsp;<a accesskey="n" href="management-chapt.html"><img src="../images/db/next.png" alt="Next"></a></td>
</tr>
<tr>
<td valign="top" align="left" width="30%">Chapter&nbsp;9.&nbsp;Triggers&nbsp;</td><td align="center" width="40%"><a accesskey="h" href="index.html"><img src="../images/db/home.png" alt="Home"></a></td><td valign="top" align="right" width="30%">&nbsp;Chapter&nbsp;11.&nbsp;System Management</td>
</tr>
</table>
</div>
<HR>
<div class="chapter" title="Chapter&nbsp;10.&nbsp;Built In Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="builtinfunctions-chapt"></a>Chapter&nbsp;10.&nbsp;Built In Functions</h2>
</div>
<div>
<div class="authorgroup">
<div class="author">
<h3 class="author">
<span class="firstname">Fred</span> <span class="surname">Toussi</span>
</h3>
<div class="affiliation">
<span class="orgname">The HSQL Development Group<br>
</span>
</div>
</div>
</div>
</div>
<div>
<p class="releaseinfo">$Revision: 5678 $</p>
</div>
<div>
<div class="legalnotice" title="Legal Notice">
<a name="N1389E"></a>
<p>Copyright 2010-2017 Fred Toussi. Permission is granted to
      distribute this document without any alteration under the terms of the
      HSQLDB license. Additional permission is granted to the HSQL Development
      Group to distribute this document with or without alterations under the
      terms of the HSQLDB license.</p>
</div>
</div>
<div>
<p class="pubdate">2017-04-09 14:14:09-0400</p>
</div>
</div>
</div>
<div class="toc">
<p>
<b>Table of Contents</b>
</p>
<dl>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_overview">Overview</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_string_binary_functions">String and Binary String Functions</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_numeric_functions">Numeric Functions</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_datetime_functions">Date Time and Interval Functions</a></span>
</dt>
<dd>
<dl>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_timezone_functions">Functions to Report the Time Zone.</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_current_datetime">Functions to Report the Current Datetime</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_extract_datetime">Functions to Extract an Element of a Datetime</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_datetime_arithmetic">Functions for Datetime Arithmetic</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_datetime_format">Functions to Convert or Format a Datetime</a></span>
</dt>
</dl>
</dd>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_array_functions">Array Functions</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_general_functions">General Functions</a></span>
</dt>
<dt>
<span class="section"><a href="builtinfunctions-chapt.html#bfc_system_functions">System Functions</a></span>
</dt>
</dl>
</div>
<div class="section" title="Overview">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_overview"></a>Overview</h2>
</div>
</div>
</div>
<p>HyperSQL supports a wide range of built-in functions and allows
    user-defined functions written in SQL and Java languages. User-defined
    functions are covered in the <a class="link" href="sqlroutines-chapt.html" title="Chapter&nbsp;8.&nbsp;SQL-Invoked Routines">SQL-Invoked Routines</a> chapter. If a built-in function is
    not available, you can write your own using procedural SQL or Java.</p>
<p>Built-in aggregate functions such as <code class="literal">SUM,</code>
    <code class="literal">MAX</code>, <code class="literal">ARRAY_AGG</code>,
    <code class="literal">GROUP_CONCAT</code> are covered in the <a class="link" href="dataaccess-chapt.html" title="Chapter&nbsp;7.&nbsp;Data Access and Change">Data Access and Change</a> chapter,
    which covers SQL in general. SQL expressions such as
    <code class="literal">COALESCE</code>, <code class="literal">NULLIF</code> and
    <code class="literal">CAST</code> are also discussed there.</p>
<p>The built-in functions fall into three groups:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>SQL Standard Functions</p>
<p>A wide rang of functions defined by SQL/Foundation are
          supported. SQL/Foundation functions that have no parameter are
          called without empty parentheses. Functions with multiple parameters
          often use keywords instead of commas to separate the parameters.
          Many functions are overloaded. Among these, some have one or more
          optional parameters that can be omitted, while the return type of
          some functions is dependent upon the type of one of the parameters.
          The usage of SQL Standard Functions (where they can be used) is
          covered more extensively in the <a class="link" href="dataaccess-chapt.html" title="Chapter&nbsp;7.&nbsp;Data Access and Change">Data Access and Change</a> chapter</p>
</li>
<li class="listitem">
<p>JDBC Open Group CLI Functions</p>
<p>These functions were defined as an extension to the CLI
          standard, which is the basis for ODBC and JDBC and supported by many
          database products. JDBC supports an escape mechanism to specify
          function calls in SQL statements in a manner that is independent of
          the function names supported by the target database engine. For
          example <code class="literal">SELECT {fn DAYOFMONTH (dateColumn)} FROM
          myTable</code> can be used in JDBC and is translated to Standard
          SQL as <code class="literal">SELECT EXTRACT (DAY_OF_MONTH FROM dateColumn) FROM
          myTable</code> if a database engine supports the Standard syntax.
          If a database engine does not support Standard SQL, then the
          translation will be different. HyperSQL supports all the function
          names specified in the JDBC specifications as native functions.
          Therefore, there is no need to use the <code class="literal">{fn FUNC_NAME ( ...
          ) }</code> escape with HyperSQL. If a JDBC function is supported
          by the SQL Standard in a different form, the SQL Standard form is
          the preferred form to use.</p>
</li>
<li class="listitem">
<p>HyperSQL Built-In Functions</p>
<p>Many additional built-in functions are available for some
          useful operations. Some of these functions return the current
          setting for the session and the database. The General Functions
          accept arguments of different types and return values based on
          comparison between the arguments.</p>
</li>
</ul>
</div>
<p>In the BNF specification used here, words in capital letters are
    actual tokens. Syntactic elements such as expressions are enclosed in
    angle brackets. The <code class="literal">&lt;left paren&gt;</code> and
    <code class="literal">&lt;right paren&gt;</code> tokens are represented with the
    actual symbol. Optional elements are enclosed with square brackets (
    <code class="literal">&lt;left bracket&gt;</code> and <code class="literal">&lt;right
    bracket&gt;</code> ). Multiple options for a required element are
    enclosed with braces (<code class="literal"> &lt;left brace&gt;</code> and
    <code class="literal">&lt;right brace&gt;</code> )<code class="literal">.</code> Alternative
    tokens are separated with the vertical bar ( <code class="literal">&lt;vertical
    bar&gt;</code> ). At the end of each function definition, the standard
    which specifies the function is noted in parentheses as JDBC or HyperSQL,
    or the SQL/Foundation part of the SQL Standard.</p>
</div>
<div class="section" title="String and Binary String Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_string_binary_functions"></a>String and Binary String Functions</h2>
</div>
</div>
</div>
<p>In SQL, there are three kinds of string: character, binary and bit.
    The units are respectively characters, octets, and bits. Each kind of
    string can be in different data types. CHAR, VARCHAR and CLOB are the
    character data types. BINARY, VARBINARY and BLOB are the binary data
    types. BIT and BIT VARYING are the bit string types. In all string
    functions, the position of a unit of the string within the whole string is
    specified from 1 to the length of the whole string. In the BNF,
    <code class="literal">&lt;char value expr&gt; </code>indicates any valid SQL
    expression that evaluates to a character type. Likewise,
    <code class="literal">&lt;binary value expr&gt; </code>indicates a binary type
    and<code class="literal"> &lt;num value expr&gt; </code>indicates a numeric
    type.</p>
<a name="N1390F" class="indexterm"></a>
<p>
<span class="bold"><strong>ASCII</strong></span>
</p>
<p>
<code class="literal">ASCII ( &lt;char value expr&gt; )</code>
</p>
<p>Returns an INTEGER equal to the ASCII code value of the first
    character of <code class="literal">&lt;char value expr&gt;</code>. (JDBC)</p>
<a name="N13920" class="indexterm"></a>
<p>
<span class="bold"><strong>BIT_LENGTH</strong></span>
</p>
<p>
<code class="literal">BIT_LENGTH ( &lt;string value expression&gt;
    )</code>
</p>
<p>BIT_LENGTH can be used with character, binary and bit strings. It
    return a BIGINT value that measures the bit length of the string.
    (Foundation)</p>
<p>See also CHARACTER_LENGTH and OCTET_LENGTH.</p>
<a name="N13930" class="indexterm"></a>
<p>
<span class="bold"><strong>CHAR</strong></span>
</p>
<p>
<code class="literal">CHAR ( &lt;UNICODE code&gt; ) </code>
</p>
<p>The argument is an INTEGER. Returns a character string containing a
    single character that has the specified<code class="literal"> &lt;UNICODE
    code&gt;</code>, which is an integer. ASCII codes are a subset of the
    allowed values for <code class="literal">&lt;UNICODE code&gt;</code>. (JDBC)</p>
<a name="N13944" class="indexterm"></a><a name="N13949" class="indexterm"></a>
<p>
<span class="bold"><strong>CHARACTER_LENGTH</strong></span>
</p>
<p>
<code class="literal">{ CHAR_LENGTH | CHARACTER_LENGTH } ( &lt;char value
    expression&gt; [ USING { CHARACTERS | OCTETS } ] )</code>
</p>
<p>The CHAR_LENGTH or CHARACTER_LENGTH function can be used with
    character strings, while OCTET_LENGTH can be used with character or binary
    strings and BIT_LENGTH can be used with character, binary and bit
    strings.</p>
<p>All functions return a BIGINT value that measures the length of the
    string in the given unit. CHAR_LENGTH counts characters, OCTET_LENGTH
    counts octets and BIT_LENGTH counts bits in the string. For CHAR_LENGTH,
    if <code class="literal">[ USING OCTETS ] </code>is specified, the octet count is
    returned, which is twice the normal length. (Foundation)</p>
<a name="N1395C" class="indexterm"></a>
<p>
<span class="bold"><strong>CONCAT</strong></span>
</p>
<p>
<code class="literal">CONCAT ( &lt;char value expr 1&gt;, &lt;char value expr
    2&gt; [, ...] )</code>
</p>
<p>
<code class="literal">CONCAT ( &lt;binary value expr 1&gt;, &lt;binary value expr
    2&gt; [, ...] )</code>
</p>
<p>The arguments are character strings or binary strings. Returns a
    string formed by concatenation of the arguments. Minimum number of
    arguments is 2. Equivalent to the SQL concatenation expression
    <code class="literal">&lt;value expr 1&gt; || &lt;value expr 2&gt; [ || ...] </code>
    .</p>
<p>Handling of null values in the CONCAT function depends on the
    database property <code class="literal">sql.concat_nulls</code> ( <code class="literal">SET
    DATABASE SQL SYNTAX CONCAT NULLS { TRUE || FALSE }</code> ). By
    default, any null value will cause the function to return null. If the
    property is set false, then NULL values are replaced with empty
    strings.</p>
<p>(JDBC)</p>
<a name="N1397A" class="indexterm"></a>
<p>
<span class="bold"><strong>CONCAT_WS</strong></span>
</p>
<p>
<code class="literal">CONCAT_WS ( &lt;char value separator&gt;, &lt;char value
    expr 1&gt;, &lt;char value expr 2&gt; [, ...] )</code>
</p>
<p>The arguments are character strings. Returns a string formed by
    concatenation of the arguments from the second argument, using the
    separator from the first argument. Minimum number of arguments is 3.
    Equivalent to the SQL concatenation expression <code class="literal">&lt;value expr
    1&gt; || &lt;separator&gt; || &lt;value expr 2&gt; [ || ...]</code> .
    The function ignores null values and returns an empty string if all values
    are null. It returns null only if the separator is null.</p>
<p>This function is similar to a MySQL function of the same
    name.</p>
<p>(HyperSQL)</p>
<a name="N1398F" class="indexterm"></a>
<p>
<span class="bold"><strong>DIFFERENCE</strong></span>
</p>
<p>
<code class="literal">DIFFERENCE ( &lt;char value expr 1&gt;, &lt;char value expr
    2&gt; )</code>
</p>
<p>The arguments are character strings. Converts the arguments into
    SOUNDEX codes, and returns an INTEGER between 0-4 which indicates how
    similar the two SOUNDEX value are. If the values are the same, it returns
    4, if the values have no similarity, it returns 0. In-between values are
    returned for partial similarity. (JDBC)</p>
<a name="N1399D" class="indexterm"></a>
<p>
<span class="bold"><strong>INSERT</strong></span>
</p>
<p>
<code class="literal">INSERT ( &lt;char value expr 1&gt;, &lt;offset&gt;,
    &lt;length&gt;, &lt;char value expr 2&gt; )</code>
</p>
<p>Returns a character string based on <code class="literal">&lt;char value expr
    1&gt;</code> in which <code class="literal">&lt;length&gt;</code> characters have
    been removed from the <code class="literal">&lt;offset&gt;</code> position and in
    their place, the whole <code class="literal">&lt;char value expr 2&gt;</code> is
    copied. Equivalent to SQL/Foundation <code class="literal">OVERLAY( &lt;char value
    expr1&gt; PLACING &lt; char value expr2&gt; FROM &lt;offset&gt; FOR
    &lt;length&gt; )</code> . (JDBC)</p>
<a name="N139BA" class="indexterm"></a>
<p>
<span class="bold"><strong>INSTR</strong></span>
</p>
<p>
<code class="literal">INSTR ( &lt;char value expr 1&gt;, &lt;char value expr
    2&gt; [ , &lt;offset&gt; ] ) </code>
</p>
<p>Returns as a BIGINT value the starting position of the first
    occurrence of <code class="literal">&lt;char value expr 2&gt;</code> within
    <code class="literal">&lt;char value expr 1&gt;</code>. If
    <code class="literal">&lt;offset</code>&gt; is specified, the search begins with the
    position indicated by <code class="literal">&lt;offset&gt;</code>. If the search is
    not successful, 0 is returned. Similar to the <code class="literal">LOCATE</code>
    function but the order of the arguments is reversed. (HyperSQL)</p>
<a name="N139D7" class="indexterm"></a>
<p>
<span class="bold"><strong>HEXTORAW</strong></span>
</p>
<p>
<code class="literal">HEXTORAW( &lt;char value expr&gt; )</code>
</p>
<p>Returns a BINARY string formed by translation of hexadecimal digits
    and letters in the &lt;<code class="literal">char value expr&gt;</code>. Each
    character of the <code class="literal">&lt;char value expr&gt;</code> must be a
    digit or a letter in the A | B | C | D | E | F set. Each byte of the
    retired binary string is formed by translating two hex digits into one
    byte. (HyperSQL)</p>
<a name="N139EB" class="indexterm"></a>
<p>
<span class="bold"><strong>LCASE</strong></span>
</p>
<p>
<code class="literal">LCASE ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a character string that is the lower case version of the
    <code class="literal">&lt;char value expr&gt;</code>. Equivalent to SQL/Foundation
    <code class="literal">LOWER (&lt;char value expr&gt;)</code>. (JDBC)</p>
<a name="N139FF" class="indexterm"></a>
<p>
<span class="bold"><strong>LEFT</strong></span>
</p>
<p>
<code class="literal">LEFT ( &lt;char value expr&gt;, &lt;count&gt; )
    </code>
</p>
<p>Returns a character string consisting of the first
    <code class="literal">&lt;count&gt;</code> characters of <code class="literal">&lt;char value
    expr&gt;</code>. Equivalent to SQL/Foundation<code class="literal">
    SUBSTRING(&lt;char value expr&gt; FROM 0 FOR &lt;count&gt;)</code>.
    (JDBC)</p>
<a name="N13A16" class="indexterm"></a>
<p>
<span class="bold"><strong>LENGTH</strong></span>
</p>
<p>
<code class="literal">LENGTH ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns as a BIGINT value the number of characters in
    <code class="literal">&lt;char value expr&gt;</code>. Equivalent to SQL/Foundation
    <code class="literal">CHAR_LENGTH(&lt;char value expr&gt;)</code>. (JDBC)</p>
<a name="N13A2A" class="indexterm"></a>
<p>
<span class="bold"><strong>LOCATE</strong></span>
</p>
<p>
<code class="literal">LOCATE ( &lt;char value expr 1&gt;, &lt;char value expr
    2&gt; [ , &lt;offset&gt; ] ) </code>
</p>
<p>Returns as a BIGINT value the starting position of the first
    occurrence of <code class="literal">&lt;char value expr 1&gt;</code> within
    <code class="literal">&lt;char value expr 2&gt;</code>. If
    <code class="literal">&lt;offset</code>&gt; is specified, the search begins with the
    position indicated by <code class="literal">&lt;offset&gt;</code>. If the search is
    not successful, 0 is returned. Without the third argument,<code class="literal">
    LOCATE</code> is equivalent to the SQL Standard function
    <code class="literal">POSITION(&lt;char value expr 1&gt; IN &lt;char value expr
    2&gt;)</code>. (JDBC)</p>
<a name="N13A4A" class="indexterm"></a>
<p>
<span class="bold"><strong>LOWER</strong></span>
</p>
<p>
<code class="literal">LOWER ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a character string that is the lower case version of the
    <code class="literal">&lt;char value expr&gt;</code>. (Foundation)</p>
<a name="N13A5B" class="indexterm"></a>
<p>
<span class="bold"><strong>LPAD</strong></span>
</p>
<p>
<code class="literal">LPAD ( &lt;char value expr 1&gt;, &lt;length&gt; [,
    &lt;char value expr 2&gt; ] ) </code>
</p>
<p>Returns a character string with the length of
    <code class="literal">&lt;length&gt;</code> characters. The string contains the
    characters of <code class="literal">&lt;char value expr 1&gt;</code> padded to the
    left with spaces. If <code class="literal">&lt;length&gt;</code> is smaller than the
    length of the string argument, the argument is truncated. If the optional
    <code class="literal">&lt;char value expr 2&gt;</code> is specified, this string is
    used for padding, instead of spaces. (HyperSQL)</p>
<a name="N13A75" class="indexterm"></a>
<p>
<span class="bold"><strong>LTRIM</strong></span>
</p>
<p>
<code class="literal">LTRIM ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a character string based on <code class="literal">&lt;char value
    expr&gt;</code> with the leading space characters removed. Equivalent
    to SQL/Foundation <code class="literal">TRIM( LEADING ' ' FROM &lt;char value expr&gt;
    )</code>. (JDBC)</p>
<a name="N13A89" class="indexterm"></a>
<p>
<span class="bold"><strong>OCTET_LENGTH</strong></span>
</p>
<p>
<code class="literal">OCTET_LENGTH ( &lt;string value expression&gt;
    )</code>
</p>
<p>The OCTET_LENGTH function can be used with character or binary
    strings.</p>
<p>Return a BIGINT value that measures the length of the string in
    octets<code class="literal">. When used with character strings</code>, the octet
    count is returned, which is twice the normal length. (Foundation)</p>
<a name="N13A9C" class="indexterm"></a>
<p>
<span class="bold"><strong>OVERLAY</strong></span>
</p>
<p>
<code class="literal">OVERLAY ( &lt;char value expr 1&gt; PLACING &lt;char value
    expr 2&gt;</code>
</p>
<p>
<code class="literal">FROM &lt;start position&gt; [ FOR &lt;string length&gt; ] [
    USING CHARACTERS ] )</code>
</p>
<p>
<code class="literal">OVERLAY ( &lt;binary value expr 1&gt; PLACING &lt;binary
    value expr 2&gt;</code>
</p>
<p>
<code class="literal">FROM &lt;start position&gt; [ FOR &lt;string length&gt; ]
    )</code>
</p>
<p>The character version of OVERLAY returns a character string based on
    <code class="literal">&lt;char value expr 1&gt;</code> in which <code class="literal">&lt;string
    length&gt;</code> characters have been removed from the
    <code class="literal">&lt;start position&gt;</code> and in their place, the whole
    <code class="literal">&lt;char value expr 2&gt;</code> is copied.</p>
<p>The binary version of OVERLAY returns a binary string formed in the
    same manner as the character version. (Foundation)</p>
<a name="N13AC1" class="indexterm"></a>
<p>
<span class="bold"><strong>POSITION</strong></span>
</p>
<p>
<code class="literal">POSITION ( &lt;char value expr 1&gt; IN &lt;char value expr
    2&gt; [ USING CHARACTERS ] )</code>
</p>
<p>
<code class="literal">POSITION ( &lt;binary value expr 1&gt; IN &lt;binary value
    expr 2&gt; )</code>
</p>
<p>The character and binary versions of POSITION search the string
    value of the second argument for the first occurrence of the first
    argument string. If the search is successful, the position in the string
    is returned as a BIGINT. Otherwise zero is returned. (Foundation)</p>
<a name="N13AD2" class="indexterm"></a>
<p>
<span class="bold"><strong>RAWTOHEX</strong></span>
</p>
<p>
<code class="literal">RAWTOHEX( &lt;binary value expr&gt; )</code>
</p>
<p>Returns a character string composed of hexadecimal digits
    representing the bytes in the <code class="literal">&lt;binary value
    expr&gt;</code>. Each byte of the <code class="literal">&lt;binary value
    expr&gt;</code> is translated into two hex digits. (HyperSQL)</p>
<a name="N13AE6" class="indexterm"></a>
<p>
<span class="bold"><strong>REGEXP_MATCHES</strong></span>
</p>
<p>
<code class="literal">REGEXP_MATCHES ( &lt;char value expr&gt;, &lt;regular
    expression&gt; ) </code>
</p>
<p>Returns true if the <code class="literal">&lt;char value expr&gt;</code>
    matches the <code class="literal">&lt;regular expression&gt;</code> as a whole. The
    <code class="literal">&lt;regular expression&gt;</code> is defined according to Java
    language regular expression rules. (HyperSQL)</p>
<a name="N13AFD" class="indexterm"></a>
<p>
<span class="bold"><strong>REGEXP_REPLACE</strong></span>
</p>
<p>
<code class="literal">REGEXP_REPLACE ( &lt;char value expr 1&gt;, &lt;regular
    expression&gt;, &lt;char value expr 3&gt; ) </code>
</p>
<p>Replaces <code class="literal">&lt;char value expr 1&gt;</code> regions that
    match the <code class="literal">&lt;regular expression&gt;</code> with
    <code class="literal">&lt;char value expr 3&gt;</code>. The <code class="literal">&lt;regular
    expression&gt;</code> is defined according to Java language regular
    expression rules. (HyperSQL)</p>
<a name="N13B17" class="indexterm"></a>
<p>
<span class="bold"><strong>REGEXP_SUBSTRING</strong></span>
</p>
<p>
<code class="literal">REGEXP_SUBSTRING ( &lt;char value expr&gt;, &lt;regular
    expression&gt; ) </code>
</p>
<p>Returns the first region in the <code class="literal">&lt;char value
    expr&gt;</code> that matches the <code class="literal">&lt;regular
    expression&gt;</code>. The <code class="literal">&lt;regular
    expression&gt;</code> is defined according to Java language regular
    expression rules. (HyperSQL)</p>
<a name="N13B2E" class="indexterm"></a>
<p>
<span class="bold"><strong>REGEXP_SUBSTRING_ARRAY</strong></span>
</p>
<p>
<code class="literal">REGEXP_SUBSTRING_ARRAY ( &lt;char value expr&gt;,
    &lt;regular expression&gt; ) </code>
</p>
<p>Returns all the regions in the the <code class="literal">&lt;char value
    expr&gt;</code> that match the <code class="literal">&lt;regular
    expression&gt;</code>. The <code class="literal">&lt;regular
    expression&gt;</code> is defined according to Java language regular
    expression rules. Returns an array containing the matching regions
    (HyperSQL)</p>
<a name="N13B45" class="indexterm"></a>
<p>
<span class="bold"><strong>REPEAT</strong></span>
</p>
<p>
<code class="literal">REPEAT ( &lt;char value expr&gt;, &lt;count&gt; )
    </code>
</p>
<p>Returns a character string based on<code class="literal"> &lt;char value
    expr&gt;</code>, repeated <code class="literal">&lt;count&gt;</code> times.
    (JDBC)</p>
<a name="N13B59" class="indexterm"></a>
<p>
<span class="bold"><strong>REPLACE</strong></span>
</p>
<p>
<code class="literal">REPLACE ( &lt;char value expr 1&gt;, &lt;char value expr
    2&gt; [, &lt;char value expr 3&gt; ] )</code>
</p>
<p>Returns a character string based on <code class="literal">&lt;char value expr
    1&gt;</code> where each occurrence of <code class="literal">&lt;char value expr
    2&gt;</code> has been replaced with a copy of <code class="literal">&lt;char value
    expr 3&gt;</code>. If the function is called with just two arguments,
    the &lt;char value expr 3&gt; defaults to the empty string and calling the
    function simply removes the occurrences of <code class="literal">&lt;char value expr
    2&gt;</code> from the first string.(JDBC)</p>
<a name="N13B73" class="indexterm"></a>
<p>
<span class="bold"><strong>REVERSE</strong></span>
</p>
<p>
<code class="literal">REVERSE ( &lt;char value expr&gt; )</code>
</p>
<p>Returns a character string based on <code class="literal">&lt;char value
    expr&gt;</code> with characters in the reverse order. (HyperSQL)</p>
<a name="N13B84" class="indexterm"></a>
<p>
<span class="bold"><strong>RIGHT</strong></span>
</p>
<p>
<code class="literal">RIGHT ( &lt;char value expr&gt;, &lt;count&gt; )
    </code>
</p>
<p>Returns a character string consisting of the last
    <code class="literal">&lt;count&gt;</code> characters of <code class="literal">&lt;char value
    expr&gt;</code>. (JDBC)</p>
<a name="N13B98" class="indexterm"></a>
<p>
<span class="bold"><strong>RPAD</strong></span>
</p>
<p>
<code class="literal">RPAD ( &lt;char value expr 1&gt;, &lt;length&gt; [,
    &lt;char value expr 2&gt; ] ) </code>
</p>
<p>Returns a character string with the length of
    <code class="literal">&lt;length&gt;</code> characters. The string begins with the
    characters of <code class="literal">&lt;char value expr 1&gt;</code> padded to the
    right with spaces. If <code class="literal">&lt;length&gt;</code> is smaller than
    the length of the string argument, the argument is truncated. If the
    optional <code class="literal">&lt;char value expr 2&gt;</code> is specified, this
    string is used for padding, instead of spaces. (HyperSQL)</p>
<a name="N13BB2" class="indexterm"></a>
<p>
<span class="bold"><strong>RTRIM</strong></span>
</p>
<p>
<code class="literal">RTRIM ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a character string based on <code class="literal">&lt;char value
    expr&gt;</code> with the trailing space characters removed. Equivalent
    to SQL/Foundation <code class="literal">TRIM(TRAILING ' ' FROM &lt;character
    string&gt;)</code>. (JDBC)</p>
<a name="N13BC6" class="indexterm"></a>
<p>
<span class="bold"><strong>SOUNDEX</strong></span>
</p>
<p>
<code class="literal">SOUNDEX ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a four character code representing the sound of
    <code class="literal">&lt;char value expr&gt;</code>. The US census algorithm is
    used. For example the soundex value for Washington is W252. (JDBC)</p>
<a name="N13BD7" class="indexterm"></a>
<p>
<span class="bold"><strong>SPACE</strong></span>
</p>
<p>
<code class="literal">SPACE ( &lt;count&gt; ) </code>
</p>
<p>Returns a character string consisting of <code class="literal">&lt;count&gt;
    </code>spaces. (JDBC)</p>
<a name="N13BE8" class="indexterm"></a>
<p>
<span class="bold"><strong>SUBSTR</strong></span>
</p>
<p>
<code class="literal">{ SUBSTR | SUBSTRING } ( &lt;char value expr&gt;,
    &lt;offset&gt;, &lt;length&gt; )</code>
</p>
<p>The JDBC version of SQL/Foundation <code class="literal">SUBSTRING</code>
    returns a character string that consists of
    <code class="literal">&lt;length&gt;</code> characters from <code class="literal">&lt;char value
    expr&gt; </code>starting at the <code class="literal">&lt;offset&gt;</code>
    position. (JDBC)</p>
<a name="N13C02" class="indexterm"></a>
<p>
<span class="bold"><strong>SUBSTRING</strong></span>
</p>
<p>
<code class="literal">SUBSTRING ( &lt;char value expr&gt; FROM &lt;start
    position&gt; [ FOR &lt;string length&gt; ] [ USING CHARACTERS ]
    )</code>
</p>
<p>
<code class="literal">SUBSTRING ( &lt;binary value expr&gt; FROM &lt;start
    position&gt; [ FOR &lt;string length&gt; ] )</code>
</p>
<p>The character version of SUBSTRING returns a character string that
    consists of the characters of the <code class="literal">&lt;char value expr&gt;
    </code>from <code class="literal">&lt;start position&gt;</code>. If the
    optional<code class="literal"> &lt;string length&gt;</code> is specified, only
    <code class="literal">&lt;string length&gt; </code>characters are returned.</p>
<p>The binary version of SUBSTRING returns a binary string in the same
    manner. (Foundation)</p>
<a name="N13C21" class="indexterm"></a>
<p>
<span class="bold"><strong>TRIM</strong></span>
</p>
<p>
<code class="literal">TRIM ([ [ LEADING | TRAILING | BOTH ] [ &lt;trim
    character&gt; ] FROM ] &lt;char value expr&gt; )</code>
</p>
<p>
<code class="literal">TRIM ([ [ LEADING | TRAILING | BOTH ] [ &lt;trim octet&gt;
    ] FROM ] &lt;binary value expr&gt; )</code>
</p>
<p>The character version of TRIM returns a character string based on
    <code class="literal">&lt;char value expr&gt;</code>. Consecutive instances of
    <code class="literal">&lt;trim character&gt; </code>are removed from the beginning,
    the end or both ends of the<code class="literal">&lt;char value expr&gt;
    </code>depending on the value of the optional first qualifier
    <code class="literal">[ LEADING | TRAILING | BOTH ]</code>. If no qualifier is
    specified, <code class="literal">BOTH </code>is used as default. If <code class="literal">[
    &lt;trim character&gt; ]</code> is not specified, the space character
    is used as default.</p>
<p>The binary version of TRIM returns a binary string based on
    <code class="literal">&lt;binary value expr&gt;</code>. Consecutive instances of
    <code class="literal">&lt;trim octet&gt; </code>are removed in the same manner as in
    the character version. If<code class="literal"> [ &lt;trim octet&gt; ]</code> is not
    specified, the 0 octet is used as default. (Foundation)</p>
<a name="N13C4F" class="indexterm"></a>
<p>
<span class="bold"><strong>TRANSLATE</strong></span>
</p>
<p>
<code class="literal">TRANSLATE( &lt;char value expr1&gt;, &lt;char value
    expr2&gt;, &lt;char value expr3&gt; )</code>
</p>
<p>Returns a character string based on <code class="literal">&lt;char value
    expr1&gt;</code> source. Each character of the source is checked
    against the characters in <code class="literal">&lt;char value expr2&gt;</code>. If
    the character is not found, it is not modified. If the character is found,
    then the character in the same position in <code class="literal">&lt;char value
    expr3&gt;</code> is used. If <code class="literal">&lt;char value
    expr2&gt;</code> is longer than <code class="literal">&lt;char value
    expr3&gt;</code>, then those characters at the end that have no
    counterpart in <code class="literal">&lt;char value expr3&gt;</code> are dropped
    from the result. (HyperSQL)</p>
<pre class="programlisting"> -- in this example any accented character in acolumn is replaced with one without an accent
 TRANSLATE( acolumn, '&Aacute;&Ccedil;&Eacute;&Iacute;&Oacute;&Uacute;&Agrave;&Egrave;&Igrave;&Ograve;&Ugrave;&Acirc;&Ecirc;&Icirc;&Ocirc;&Ucirc;&Atilde;&Otilde;&Euml;&Uuml;&aacute;&ccedil;&eacute;&iacute;&oacute;&uacute;&agrave;&egrave;&igrave;&ograve;&ugrave;&acirc;&ecirc;&icirc;&ocirc;&ucirc;&atilde;&otilde;&euml;&uuml;', 'ACEIOUAEIOUAEIOUAOEUaceiouaeiouaeiouaoeu');
</pre>
<a name="N13C71" class="indexterm"></a>
<p>
<span class="bold"><strong>UCASE</strong></span>
</p>
<p>
<code class="literal">UCASE ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a character string that is the upper case version of the
    <code class="literal">&lt;char value expr&gt;</code>. Equivalent to SQL/Foundation
    <code class="literal">UPPER( &lt;char value expr&gt; )</code> . (JDBC)</p>
<a name="N13C85" class="indexterm"></a>
<p>
<span class="bold"><strong>UPPER</strong></span>
</p>
<p>
<code class="literal">UPPER ( &lt;char value expr&gt; ) </code>
</p>
<p>Returns a character string that is the upper case version of the
    <code class="literal">&lt;char value expr&gt;</code> . (Foundation)</p>
</div>
<div class="section" title="Numeric Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_numeric_functions"></a>Numeric Functions</h2>
</div>
</div>
</div>
<a name="N13C9A" class="indexterm"></a>
<p>
<span class="bold"><strong>ABS</strong></span>
</p>
<p>
<code class="literal">ABS ( &lt;num value expr&gt; | &lt;interval value expr&gt;
    ) </code>
</p>
<p>Returns the absolute value of the argument as a value of the same
    type. (JDBC and Foundation)</p>
<a name="N13CA8" class="indexterm"></a>
<p>
<span class="bold"><strong>ACOS</strong></span>
</p>
<p>
<code class="literal">ACOS ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the arc-cosine of the argument in radians as a value of
    DOUBLE type. (JDBC)</p>
<a name="N13CB6" class="indexterm"></a>
<p>
<span class="bold"><strong>ASIN</strong></span>
</p>
<p>
<code class="literal">ASIN ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the arc-sine of the argument in radians as a value of DOUBLE
    type. (JDBC)</p>
<a name="N13CC4" class="indexterm"></a>
<p>
<span class="bold"><strong>ATAN</strong></span>
</p>
<p>
<code class="literal">ATAN ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the arc-tangent of the argument in radians as a value of
    DOUBLE type. (JDBC)</p>
<a name="N13CD2" class="indexterm"></a>
<p>
<span class="bold"><strong>ATAN2</strong></span>
</p>
<p>
<code class="literal">ATAN2 ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt;
    ) </code>
</p>
<p>The <code class="literal">&lt;num value expr 1&gt;</code> and <code class="literal">&lt;num
    value expr 2&gt;</code> express the <code class="varname">x</code> and
    <code class="varname">y</code> coordinates of a point. Returns the angle, in
    radians, representing the angle coordinate of the point in polar
    coordinates, as a value of DOUBLE type. (JDBC)</p>
<a name="N13CEC" class="indexterm"></a>
<p>
<span class="bold"><strong>CEILING</strong></span>
</p>
<p>
<code class="literal">{ CEIL | CEILING } ( &lt;num value expr&gt; )
    </code>
</p>
<p>Returns the smallest integer greater than or equal to the argument.
    If the argument is exact numeric then the result is exact numeric with a
    scale of 0. If the argument is approximate numeric, then the result is of
    DOUBLE type. (JDBC and Foundation)</p>
<a name="N13CFA" class="indexterm"></a>
<p>
<span class="bold"><strong>BITAND</strong></span>
</p>
<p>
<code class="literal">BITAND ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt;
    )</code>
</p>
<p>
<code class="literal">BITAND ( &lt;bit value expr 1&gt;, &lt;bit value expr 2&gt;
    )</code>
</p>
<a name="N13D09" class="indexterm"></a>
<p>
<span class="bold"><strong>BITANDNOT</strong></span>
</p>
<p>
<code class="literal">BITANDNOT ( &lt;num value expr 1&gt;, &lt;num value expr
    2&gt; )</code>
</p>
<p>
<code class="literal">BITANDNOT ( &lt;bit value expr 1&gt;, &lt;bit value expr
    2&gt; )</code>
</p>
<a name="N13D18" class="indexterm"></a>
<p>
<span class="bold"><strong>BITNOT</strong></span>
</p>
<p>
<code class="literal">BITNOT ( &lt;num value expr 1&gt; )</code>
</p>
<p>
<code class="literal">BITNOT ( &lt;bit value expr 1&gt; )</code>
</p>
<a name="N13D27" class="indexterm"></a>
<p>
<span class="bold"><strong>BITOR</strong></span>
</p>
<p>
<code class="literal">BITOR ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt;
    )</code>
</p>
<p>
<code class="literal">BITOR ( &lt;bit value expr 1&gt;, &lt;bit value expr 2&gt;
    )</code>
</p>
<a name="N13D36" class="indexterm"></a>
<p>
<span class="bold"><strong>BITXOR</strong></span>
</p>
<p>
<code class="literal">BITXOR ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt;
    )</code>
</p>
<p>
<code class="literal">BITXOR ( &lt;bit value expr 1&gt;, &lt;bit value expr 2&gt;
    )</code>
</p>
<p>These functions bit operations on two values, or in the case of
    BITNOT on a single values. The values are either integer values, or bit
    strings. The result is an integer value of the same type as the arguments,
    or a bit string of the same length as the argument. Each bit of the result
    is formed by performing the operation on corresponding bits of the
    arguments. The names of the function indicate NOT, OR, AND, XOR
    operations. The BITANDNOT performs NOT on the second argument, then
    performs AND on result and the first argument. (HyperSQL)</p>
<a name="N13D47" class="indexterm"></a>
<p>
<span class="bold"><strong>COS</strong></span>
</p>
<p>
<code class="literal">COS ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the cosine of the argument (an angle expressed in radians)
    as a value of DOUBLE type. (JDBC)</p>
<a name="N13D55" class="indexterm"></a>
<p>
<span class="bold"><strong>COSH</strong></span>
</p>
<p>
<code class="literal">COSH ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the hyperbolic cosine of the argument as a value of DOUBLE
    type. (HyperSQL)</p>
<a name="N13D63" class="indexterm"></a>
<p>
<span class="bold"><strong>COT</strong></span>
</p>
<p>
<code class="literal">COT ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the cotangent of the argument as a value of DOUBLE type. The
    <code class="literal">&lt;num value expr&gt;</code> represents an angle expressed in
    radians. (JDBC)</p>
<a name="N13D74" class="indexterm"></a>
<p>
<span class="bold"><strong>DEGREES</strong></span>
</p>
<p>
<code class="literal">DEGREES ( &lt;num value expr&gt; ) </code>
</p>
<p>Converts the argument (an angle expressed in<code class="literal">
    radians</code>) into degrees and returns the value in the DOUBLE type.
    (JDBC)</p>
<a name="N13D85" class="indexterm"></a>
<p>
<span class="bold"><strong>EXP</strong></span>
</p>
<p>
<code class="literal">EXP ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the exponential value of the argument as a value of DOUBLE
    type. (JDBC and Foundation)</p>
<a name="N13D93" class="indexterm"></a>
<p>
<span class="bold"><strong>FLOOR</strong></span>
</p>
<p>
<code class="literal">FLOOR ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the largest integer that is less than or equal to the
    argument. If the argument is exact numeric then the result is exact
    numeric with a scale of 0. If the argument is approximate numeric, then
    the result is of DOUBLE type. (JDBC and Foundation)</p>
<a name="N13DA1" class="indexterm"></a>
<p>
<span class="bold"><strong>LN</strong></span>
</p>
<p>
<code class="literal">LN ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the natural logarithm of the argument, as a value of DOUBLE
    type. (Foundation)</p>
<a name="N13DAF" class="indexterm"></a>
<p>
<span class="bold"><strong>LOG</strong></span>
</p>
<p>
<code class="literal">LOG ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the natural logarithm of the argument, as a value of DOUBLE
    type. (JDBC)</p>
<a name="N13DBD" class="indexterm"></a>
<p>
<span class="bold"><strong>LOG10</strong></span>
</p>
<p>
<code class="literal">LOG10 ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the base 10 logarithm of the argument as a value of DOUBLE
    type. (JDBC)</p>
<a name="N13DCB" class="indexterm"></a>
<p>
<span class="bold"><strong>MOD</strong></span>
</p>
<p>
<code class="literal">MOD ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt; )
    </code>
</p>
<p>Returns the remainder (modulus) of <code class="literal">&lt;num value expr
    1&gt;</code> divided by <code class="literal">&lt;num value expr 2&gt;.</code>
    The data type of the returned value is the same as the second argument.
    (JDBC and Foundation)</p>
<a name="N13DDF" class="indexterm"></a>
<p>
<span class="bold"><strong>NANVL</strong></span>
</p>
<p>
<code class="literal">NANVL ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt;
    ) </code>
</p>
<p>Returns an alternative for the NaN (Not a Number) double value in
    <code class="literal">&lt;num value expr 1&gt;</code> as <code class="literal">&lt;num value expr
    2&gt;.</code>, otherwise returns the first argument. The data type of
    the returned value is DOUBLE. (HyperSQL)</p>
<a name="N13DF3" class="indexterm"></a>
<p>
<span class="bold"><strong>PI</strong></span>
</p>
<p>
<code class="literal">PI () </code>
</p>
<p>Returns the constant pi as a value of DOUBLE type. (JDBC)</p>
<a name="N13E01" class="indexterm"></a>
<p>
<span class="bold"><strong>POWER</strong></span>
</p>
<p>
<code class="literal">POWER ( &lt;num value expr 1&gt;, &lt;num value expr 2&gt;
    ) </code>
</p>
<p>Returns the value of <code class="literal">&lt;num value expr 1&gt;</code>
    raised to the power of <code class="literal">&lt;int value expr 2&gt;</code> as a
    value of DOUBLE type. (JDBC and Foundation)</p>
<a name="N13E15" class="indexterm"></a>
<p>
<span class="bold"><strong>RADIANS</strong></span>
</p>
<p>
<code class="literal">RADIANS ( &lt;num value expr&gt; ) </code>
</p>
<p>Converts the argument (an angle expressed in<code class="literal">
    degrees</code>) into radians and returns the value in the DOUBLE type.
    (JDBC)</p>
<a name="N13E26" class="indexterm"></a>
<p>
<span class="bold"><strong>RAND</strong></span>
</p>
<p>
<code class="literal">RAND ( [ &lt;int value expr&gt; ] ) </code>
</p>
<p>Returns a random value in the DOUBLE type. The optional <code class="literal">[
    &lt;int value expr&gt; ]</code> is used as seed value. In HyperSQL each
    session has a separate random number generator. The first call that uses a
    seed parameter sets the seed for subsequent calls that do not include a
    parameter. (JDBC)</p>
<a name="N13E37" class="indexterm"></a>
<p>
<span class="bold"><strong>ROUND</strong></span>
</p>
<p>
<code class="literal">ROUND ( &lt;num value expr&gt;, &lt;int value expr&gt; )
    </code>
</p>
<p>The <code class="literal">&lt;num value expr&gt; </code>is of the DOUBLE type
    or DECIMAL type. The function returns a DOUBLE or DECIMAL value which is
    the value of the argument rounded to <code class="literal">&lt;int value
    expr&gt;</code> places right of the decimal point. If <code class="literal">&lt;int
    value expr&gt;</code> is negative, the first argument is rounded to
    <code class="literal">&lt;int value expr&gt;</code> places to the left of the
    decimal point.</p>
<p>This function rounds values ending with .5 or larger away from zero
    for DECIMAL arguments and results. When the value ends with .5 or larger
    and the argument and result are DOUBLE, It rounds the value towards the
    closest even value.</p>
<p>The datetime version is discussed in the next section. (JDBC)</p>
<a name="N13E55" class="indexterm"></a>
<p>
<span class="bold"><strong>SIGN</strong></span>
</p>
<p>
<code class="literal">SIGN ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns an INTEGER, indicating the sign of the argument. If the
    argument is negative then -1 is returned. If it is equal to zero then 0 is
    returned. If the argument is positive then 1 is returned. (JDBC)</p>
<a name="N13E63" class="indexterm"></a>
<p>
<span class="bold"><strong>SIN</strong></span>
</p>
<p>
<code class="literal">SIN ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the sine of the argument (an angle expressed in radians) as
    a value of DOUBLE type. (JDBC)</p>
<a name="N13E71" class="indexterm"></a>
<p>
<span class="bold"><strong>SINH</strong></span>
</p>
<p>
<code class="literal">SINH ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the hyperbolic sine of the argument as a value of DOUBLE
    type. (HyperSQL)</p>
<a name="N13E7F" class="indexterm"></a>
<p>
<span class="bold"><strong>SQRT</strong></span>
</p>
<p>
<code class="literal">SQRT ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the square root of the argument as a value of DOUBLE type.
    (JDBC and Foundation)</p>
<a name="N13E8D" class="indexterm"></a>
<p>
<span class="bold"><strong>TAN</strong></span>
</p>
<p>
<code class="literal">TAN ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the tangent of the argument (an angle expressed in radians)
    as a value of DOUBLE type. (JDBC)</p>
<a name="N13E9B" class="indexterm"></a>
<p>
<span class="bold"><strong>TANH</strong></span>
</p>
<p>
<code class="literal">TANH ( &lt;num value expr&gt; ) </code>
</p>
<p>Returns the hyperbolic tangent of the argument as a value of DOUBLE
    type. (HyperSQL)</p>
<a name="N13EA9" class="indexterm"></a>
<p>
<span class="bold"><strong>TO_NUMBER</strong></span>
</p>
<p>
<code class="literal">TO_NUMBER ( &lt;char value expr&gt; ) </code>
</p>
<p>Performs a cast from character to DECIMAL number. The character
    string must consist of digits and can have a decimal point. Use the SQL
    Standard CAST expression instead of this non-standard function.
    (HyperSQL)</p>
<a name="N13EB7" class="indexterm"></a>
<p>
<span class="bold"><strong>TRUNC</strong></span>
</p>
<p>
<code class="literal">TRUNC ( &lt;num value expr&gt; [, &lt;int value expr&gt;] )
    </code>
</p>
<p>This is a similar to the <code class="literal">TRUNCATE</code> function when
    the first argument is numeric. If the second argument is omitted, zero is
    used in its place.</p>
<p>The datetime version is discussed in the next section.
    (HyperSQL)</p>
<a name="N13ECA" class="indexterm"></a>
<p>
<span class="bold"><strong>TRUNCATE</strong></span>
</p>
<p>
<code class="literal">TRUNCATE ( &lt;num value expr&gt; [, &lt;int value
    expr&gt;] ) </code>
</p>
<p>Returns a value in the same type as <code class="literal">&lt;num value
    expr&gt;</code> but may reduce the scale of DECIMAL and NUMERIC values.
    The value is rounded by replacing digits with zeros from <code class="literal">&lt;int
    value expr&gt;</code> places right of the decimal point to the end. If
    <code class="literal">&lt;int value expr&gt;</code> is negative, <code class="literal">ABS(
    &lt;int value expr&gt; )</code> digits to left of the decimal point and
    all digits to the right of the decimal points are replaced with zeros.
    Results of calling TRUNCATE with 12345.6789 with (-2, 0, 2, 4) are (12300,
    12345, 12345.67, 12345.6789). The function does not change the number if
    the second argument is larger than or equal to the scale of the first
    argument.</p>
<p>If the second argument is not a constant (when it is a parameter or
    column reference) then the type of the return value is always the same as
    the type of the first argument. In this case, the discarded digits are
    replaced with zeros. (JDBC)</p>
<a name="N13EE6" class="indexterm"></a>
<p>
<span class="bold"><strong>WIDTH_BUCKET</strong></span>
</p>
<p>
<code class="literal">WIDTH_BUCKET ( &lt;value expr 1&gt; , &lt;value expr 2&gt;,
    &lt;value expr 3&gt;, &lt;int value expr&gt; ) </code>
</p>
<p>Returns an integer value between 0 and <code class="literal">&lt;int value
    expr&gt; + 1</code>. The initial three parameters are of the same
    numeric or datetime type. The range, ( <code class="literal">&lt;value expr 2&gt; ,
    &lt;value expr 3&gt;</code> ) is divided into <code class="literal">&lt;int value
    expr&gt;</code> equal sections (buckets). The returned integer value
    indicates the index of the bucket where <code class="literal">&lt;value expr
    1&gt;</code> can be placed. If the <code class="literal">&lt;value expr
    1&gt;</code> falls before or after the range, the return value is 0 or
    <code class="literal">&lt;value expr 1&gt; + 1</code> respectively.</p>
<p>This function can be used with numeric or datetime values. Invalid
    arguments, including <code class="literal">&lt;int value expr&gt;</code> smaller
    than 1, or equal values for <code class="literal">&lt;value expr 2&gt;</code> and
    <code class="literal">&lt;value expr 3&gt;</code> will cause an exception.
    (Foundation)</p>
<p>An example is given below:</p>
<pre class="programlisting"> WIDTH_BUCKET( 5, 10, 110, 10)
 0

 WIDTH_BUCKET( 23, 10, 110, 10)
 2

 WIDTH_BUCKET( 100, 10, 110, 10)
 10

 WIDTH_BUCKET( 200, 10, 110, 10)
 11
</pre>
</div>
<div class="section" title="Date Time and Interval Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_datetime_functions"></a>Date Time and Interval Functions</h2>
</div>
</div>
</div>
<p>Functions to report the time zone.</p>
<div class="section" title="Functions to Report the Time Zone.">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="bfc_timezone_functions"></a>Functions to Report the Time Zone.</h3>
</div>
</div>
</div>
<a name="N13F1F" class="indexterm"></a>
<p>
<span class="bold"><strong>TIMEZONE</strong></span>
</p>
<p>
<code class="literal">TIMEZONE()</code>
</p>
<p>Returns the current time zone for the session. Returns an INTERVAL
      HOUR TO MINUTE value. (HyperSQL)</p>
<a name="N13F2D" class="indexterm"></a>
<p>
<span class="bold"><strong>SESSION_TIMEZONE</strong></span>
</p>
<p>
<code class="literal">SESSION_TIMEZONE()</code>
</p>
<p>Returns the default time zone for the current session. Returns an
      INTERVAL HOUR TO MINUTE value. (HyperSQL)</p>
<a name="N13F3B" class="indexterm"></a>
<p>
<span class="bold"><strong>SESSIONTIMEZONE</strong></span>
</p>
<p>
<code class="literal">SESSIONTIMEZONE()</code>
</p>
<p>Same as SESSION_TIMEZONE. (HyperSQL)</p>
<a name="N13F49" class="indexterm"></a>
<p>
<span class="bold"><strong>DATABASE_TIMEZONE</strong></span>
</p>
<p>
<code class="literal">DATABASE_TIMEZONE()</code>
</p>
<p>Returns the time zone for the database engine. This is based on
      where the database server process is located. Returns an INTERVAL HOUR
      TO MINUTE value. (HyperSQL)</p>
<p>
<span class="bold"><strong>DBTIMEZONE</strong></span>
</p>
<p>
<code class="literal">DBTIMEZONE()</code>
</p>
<p>Same as DATABASE_TIMEZONE. (HyperSQL)</p>
</div>
<div class="section" title="Functions to Report the Current Datetime">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="bfc_current_datetime"></a>Functions to Report the Current Datetime</h3>
</div>
</div>
</div>
<a name="N13F64" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_DATE</strong></span>
</p>
<p>
<code class="literal">CURRENT_DATE</code>
</p>
<a name="N13F70" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_TIME</strong></span>
</p>
<p>
<code class="literal">CURRENT_TIME [ ( &lt;time precision&gt; )
      ]</code>
</p>
<a name="N13F7C" class="indexterm"></a>
<p>
<span class="bold"><strong>LOCALTIME</strong></span>
</p>
<p>
<code class="literal">LOCALTIME [ ( &lt;time precision&gt; ) ]</code>
</p>
<a name="N13F88" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_TIMESTAMP</strong></span>
</p>
<p>
<code class="literal">CURRENT_TIMESTAMP [ ( &lt;timestamp precision&gt; )
      ]</code>
</p>
<a name="N13F94" class="indexterm"></a>
<p>
<span class="bold"><strong>LOCALTIMESTAMP</strong></span>
</p>
<p>
<code class="literal">LOCALTIMESTAMP [ ( &lt;timestamp precision&gt; )
      ]</code>
</p>
<p>These datetime functions return the datetime value representing
      the moment the function is called. CURRENT_DATE returns a value of DATE
      type. CURRENT_TIME returns a value of TIME WITH TIME ZONE type.
      LOCALTIME returns a value of TIME type. CURRENT_TIMESTAMP returns a
      value of TIMESTAMP WITH TIME ZONE type. LOCALTIMESTAMP returns a value
      of TIMESTAMP type. If the optional <code class="literal">[ ( &lt;time precision&gt; )
      ]</code> or<code class="literal"> [ ( &lt;timestamp precision&gt; ) ]</code> is
      used, then the returned value has the specified fraction of the second
      precision. (Foundation)</p>
<a name="N13FA8" class="indexterm"></a>
<p>
<span class="bold"><strong>NOW</strong></span>
</p>
<p>
<code class="literal">NOW ()</code>
</p>
<p>This function is equivalent to <code class="literal">LOCALTIMESTAMP</code>.
      It can be used as a no-arg function as the parens are optional.
      (HyperSQL)</p>
<a name="N13FB9" class="indexterm"></a>
<p>
<span class="bold"><strong>CURDATE</strong></span>
</p>
<p>
<code class="literal">CURDATE ()</code>
</p>
<p>This function is equivalent to<code class="literal"> CURRENT_DATE</code>.
      (JDBC)</p>
<a name="N13FCA" class="indexterm"></a>
<p>
<span class="bold"><strong>CURTIME</strong></span>
</p>
<p>
<code class="literal">CURTIME ()</code>
</p>
<p>This function is equivalent to<code class="literal"> LOCALTIME</code>.
      (JDBC)</p>
<a name="N13FDB" class="indexterm"></a>
<p>
<span class="bold"><strong>SYSDATE</strong></span>
</p>
<p>
<code class="literal">SYSDATE</code>
</p>
<p>This function is similar to <code class="literal">LOCALTIMESTAMP </code>but
      it returns the timestamp when it is called. (HyperSQL)</p>
<a name="N13FEC" class="indexterm"></a>
<p>
<span class="bold"><strong>SYSTIMESTAMP</strong></span>
</p>
<p>
<code class="literal">SYSTIMESTAMP</code>
</p>
<p>This no-arg function is similar to
      <code class="literal">CURRENT_TIMESTAMP</code> and is enabled in ORA syntax mode
      only. It returns the timestamp when it is called. (HyperSQL)</p>
<a name="N13FFD" class="indexterm"></a>
<p>
<span class="bold"><strong>TODAY</strong></span>
</p>
<p>
<code class="literal">TODAY</code>
</p>
<p>This no-arg function is equivalent to<code class="literal"> CURRENT_DATE.
      </code>(HyperSQL)</p>
</div>
<div class="section" title="Functions to Extract an Element of a Datetime">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="bfc_extract_datetime"></a>Functions to Extract an Element of a Datetime</h3>
</div>
</div>
</div>
<a name="N14012" class="indexterm"></a>
<p>
<span class="bold"><strong>DATENAME, DATEPART and
      EOMONTH</strong></span>
</p>
<p>These functions are available in the MSS compatibility mode and
      perform the equivalent of EXTRACT function or the LAST_DAY function.
      (HyperSQL)</p>
<a name="N1401D" class="indexterm"></a>
<p>
<span class="bold"><strong>DAYNAME</strong></span>
</p>
<p>
<code class="literal">DAYNAME ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to<code class="literal"> EXTRACT ( DAY_NAME FROM
      ... ) </code>Returns a string in the range of Sunday - Saturday.
      (JDBC)</p>
<a name="N1402E" class="indexterm"></a>
<p>
<span class="bold"><strong>DAYOFMONTH</strong></span>
</p>
<p>
<code class="literal">DAYOFMONTH ( &lt;datetime value expr&gt;
      )</code>
</p>
<p>This function is equivalent to<code class="literal"> EXTRACT ( DAY_OF_MONTH
      FROM ... ) </code>Returns an integer value in the range of 1-31.
      (JDBC)</p>
<a name="N1403F" class="indexterm"></a>
<p>
<span class="bold"><strong>DAYOFWEEK</strong></span>
</p>
<p>
<code class="literal">DAYOFWEEK ( &lt;datetime value expr&gt;
      )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( DAY_OF_WEEK FROM
      ... ) </code>Returns an integer value in the range of 1-7. The first
      day of the week is Sunday. (JDBC)</p>
<a name="N14050" class="indexterm"></a>
<p>
<span class="bold"><strong>DAYOFYEAR</strong></span>
</p>
<p>
<code class="literal">DAYOFYEAR ( &lt;datetime value expr&gt;
      )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( DAY_OF_YEAR FROM
      ... ) </code>Returns an integer value in the range of 1-366.
      (JDBC)</p>
<a name="N14061" class="indexterm"></a>
<p>
<span class="bold"><strong>DAYS</strong></span>
</p>
<p>
<code class="literal">DAYS ( &lt;datetime value expr&gt; ) </code>
</p>
<p>The <code class="literal">&lt;datetime value expr&gt; </code>is of DATE or
      TIMESTAMP type. This function returns the DAY number since the first day
      of the calendar. The first day is numbered 1. (HyperSQL)</p>
<a name="N14072" class="indexterm"></a>
<p>
<span class="bold"><strong>HOUR</strong></span>
</p>
<p>
<code class="literal">HOUR ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( HOUR FROM ... )
      </code>Returns an integer value in the range of 0-23. (JDBC)</p>
<a name="N14083" class="indexterm"></a>
<p>
<span class="bold"><strong>MINUTE</strong></span>
</p>
<p>
<code class="literal">MINUTE ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to<code class="literal"> EXTRACT ( MINUTE FROM ...
      ) </code>Returns an integer value in the range of 0 - 59.
      (JDBC)</p>
<a name="N14094" class="indexterm"></a>
<p>
<span class="bold"><strong>MONTH</strong></span>
</p>
<p>
<code class="literal">MONTH ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( MONTH FROM ... )
      </code>Returns an integer value in the range of 1-12. (JDBC)</p>
<a name="N140A5" class="indexterm"></a>
<p>
<span class="bold"><strong>MONTHNAME</strong></span>
</p>
<p>
<code class="literal">MONTHNAME ( &lt;datetime value expr&gt;
      )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( NAME_OF_MONTH
      FROM ... ) </code>Returns a string in the range of January -
      December. (JDBC)</p>
<a name="N140B6" class="indexterm"></a>
<p>
<span class="bold"><strong>QUARTER</strong></span>
</p>
<p>
<code class="literal">QUARTER ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( QUARTER FROM ...
      ) </code>Returns an integer in the range of 1 - 4. (JDBC)</p>
<a name="N140C7" class="indexterm"></a>
<p>
<span class="bold"><strong>SECOND</strong></span>
</p>
<p>
<code class="literal">SECOND ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to <code class="literal">EXTRACT ( SECOND FROM ...
      ) </code>Returns an integer or decimal in the range of 0 - 59, with
      the same precision as the &lt;datetime value expr&gt;. (JDBC)</p>
<a name="N140D8" class="indexterm"></a>
<p>
<span class="bold"><strong>SECONDS_SINCE_MIDNIGHT</strong></span>
</p>
<p>
<code class="literal">SECONDS_SINCE_MIDNIGHT ( &lt;datetime value expr&gt;
      )</code>
</p>
<p>This function is equivalent to<code class="literal"> EXTRACT (
      SECONDS_SINCE_MIDNIGHT FROM ... ) </code>Returns an integer in the
      range of 0 - 86399. (HyperSQL)</p>
<a name="N140E9" class="indexterm"></a>
<p>
<span class="bold"><strong>UNIX_MILLIS</strong></span>
</p>
<p>
<code class="literal">UNIX_MILLIS ( [ &lt;datetime value expression&gt; ] )
      </code>
</p>
<p>This function returns a BIGINT value. With no parameter, it
      returns the number of milliseconds since 1970-01-01. With a DATE or
      TIMESTAMP parameter, it converts the argument into number of
      milliseconds since 1970-01-01. (HyperSQL)</p>
<a name="N140F7" class="indexterm"></a>
<p>
<span class="bold"><strong>UNIX_TIMESTAMP</strong></span>
</p>
<p>
<code class="literal">UNIX_TIMESTAMP ( [ &lt;datetime value expression&gt; ] )
      </code>
</p>
<p>This function returns a BIGINT value. With no parameter, it
      returns the number of seconds since 1970-01-01. With a DATE or TIMESTAMP
      parameter, it converts the argument into number of seconds since
      1970-01-01. The TIMESTAMP ( &lt;num value expression&gt; function
      returns a TIMESTAMP from a Unix timestamp. (HyperSQL)</p>
<a name="N14105" class="indexterm"></a>
<p>
<span class="bold"><strong>WEEK</strong></span>
</p>
<p>
<code class="literal">WEEK ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to<code class="literal"> EXTRACT ( WEEK_OF_YEAR
      FROM ... ) </code>Returns an integer in the range of 1 - 54.
      (JDBC)</p>
<a name="N14116" class="indexterm"></a>
<p>
<span class="bold"><strong>YEAR</strong></span>
</p>
<p>
<code class="literal">YEAR ( &lt;datetime value expr&gt; )</code>
</p>
<p>This function is equivalent to<code class="literal"> EXTRACT ( YEAR FROM ... )
      </code>Returns an integer in the range of 1 - 9999. (JDBC)</p>
<a name="N14127" class="indexterm"></a>
<p>
<span class="bold"><strong>EXTRACT</strong></span>
</p>
<p>
<code class="literal">EXTRACT ( &lt;extract field&gt; FROM &lt;extract
      source&gt; )</code>
</p>
<p>
<code class="literal">&lt;extract field&gt; ::= YEAR | MONTH | DAY | HOUR |
      MINUTE | DAY_OF_WEEK | WEEK_OF_YEAR | QUARTER | DAY_OF_YEAR |
      DAY_OF_MONTH |</code>
</p>
<p>
<code class="literal">TIMEZONE_HOUR | TIMEZONE_MINUTE | SECOND |
      SECONDS_SINCE_MIDNIGHT |</code>
</p>
<p>
<code class="literal">DAY_NAME | MONTH_NAME</code>
</p>
<p>
<code class="literal">&lt;extract source&gt; ::= &lt;datetime value expr&gt; |
      &lt;interval value expr&gt;</code>
</p>
<p>The EXTRACT function returns a field or element of the
      <code class="literal">&lt;extract source&gt;</code>. The <code class="literal">&lt;extract
      source&gt;</code> is a datetime or interval expression. The type of
      the return value is BIGINT for most of the<code class="literal"> &lt;extract
      field&gt;</code> options. The exceptions is <code class="literal">SECOND
      </code>where a DECIMAL value is returned which has the same precision
      as the datetime or interval expression. The field values
      <code class="literal">DAY_NAME </code>or<code class="literal"> MONTH_NAME </code>result in a
      character string. When <code class="literal">MONTH_NAME</code> is specified, a
      string in the range January - December is returned. When
      <code class="literal">DAY_NAME </code>is specified, a string in the range Sunday
      -Saturday is returned.</p>
<p>If the <code class="literal">&lt;extract source&gt;</code> is <code class="literal">FROM
      &lt;datetime value expr&gt;</code>, different groups of
      <code class="literal">&lt;extract source&gt;</code> can be used depending on the
      data type of the expression. The <code class="literal">TIMEZONE_HOUR |
      TIMEZONE_MINUTE</code> options are valid only for TIME WITH TIMEZONE
      and TIMESTAMP WITH TIMEZONE data types. The <code class="literal">HOUR | MINUTE |
      SECOND | SECONDS_MIDNIGHT</code> options, are valid for TIME and
      TIMESTAMP types. The rest of the fields are valid for DATE and TIMESTAMP
      types.</p>
<p>If the <code class="literal">&lt;extract source&gt;</code> is <code class="literal">FROM
      &lt;interval value expr&gt;</code>, the <code class="literal">&lt;extract
      field&gt;</code> must be one of the fields of the INTERVAL type of
      the expressions. The <code class="literal">YEAR | MONTH</code> options may be
      valid for INTERVAL types based on months. The <code class="literal">DAY | HOUR |
      MINUTE | SECOND | SECONDS_MIDNIGHT</code> options may be valid for
      INTERVAL types based on seconds. For example,<code class="literal"> DAY | HOUR |
      MINUTE</code> are the only valid fields for the INTERVAL DAY TO
      MINUTE data type. (Foundation with HyperSQL extensions)</p>
</div>
<div class="section" title="Functions for Datetime Arithmetic">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="bfc_datetime_arithmetic"></a>Functions for Datetime Arithmetic</h3>
</div>
</div>
</div>
<a name="N14182" class="indexterm"></a>
<p>
<span class="bold"><strong>NEXT_DAY</strong></span>
</p>
<p>
<code class="literal">NEXT_DAY ( &lt;datetime value expr&gt;, &lt;character
      value expr&gt;)</code>
</p>
<p>This function returns a value of the same type as the first
      argument. The return value is the next weekday named by the second
      argument that occurs after the first date. For example next Wednesday is
      expressed as <code class="literal">NEXT_DAY(CURRENT_DATE, 'WEDNESDAY')</code>.
      (HyperSQL)</p>
<a name="N14193" class="indexterm"></a>
<p>
<span class="bold"><strong>ADD_MONTHS</strong></span>
</p>
<p>
<code class="literal">ADD_MONTHS ( &lt;datetime value expr&gt;, &lt;numeric
      value expr&gt;)</code>
</p>
<p>This function is similar but different to simple addition a MONTH
      interval to a datetime value. The SQL Standard expression,
      <code class="literal">&lt;datetime value expr&gt; + n MONTH</code>, when used with
      the last day of a short month such as February, returns a date that has
      the same day of the month in the target month. The
      <code class="literal">ADD_MONTHS</code> function adjusts the target day to the
      last day of the target month. For all other days, the behaviour is the
      same. This function always returns a TIMESTAMP(0) value, regardless of
      the type of the argument. (HyperSQL)</p>
<p>The example below compares the output of the function and the
      expression.</p>
<pre class="programlisting"> VALUES ADD_MONTHS ( DATE '2012-02-29' , 1), DATE '2012-02-29' + 1 MONTH

 C1                  C2         
 ------------------- ---------- 
 2012-03-31 00:00:00 2012-03-29 
</pre>
<a name="N141AC" class="indexterm"></a>
<p>
<span class="bold"><strong>LAST_DAY</strong></span>
</p>
<p>
<code class="literal">LAST_DAY ( &lt;datetime value expr&gt; )</code>
</p>
<p>Returns the last day of the month for the given
      <code class="literal">&lt;datetime value expr&gt;</code>. The returned value
      preserves the year, month, hour, minute and secend fields of the
      timestamp. The type of the result is always TIMESTAMP(0).
      (HyperSQL)</p>
<pre class="programlisting"> VALUES LAST_DAY ( TIMESTAMP '2012-02-14 12:30:44')

 C1                  
 ------------------- 
 2012-02-29 12:30:44 
</pre>
<a name="N141C0" class="indexterm"></a>
<p>
<span class="bold"><strong>MONTHS_BETWEEN</strong></span>
</p>
<p>
<code class="literal">MONTHS_BETWEEN ( &lt;datetime value expr1&gt; ,
      &lt;datetime value expr2&gt; )</code>
</p>
<p>Returns the a number (not an INTERVAL) possibly with a fraction,
      representing the number of months between two days. If both dates have
      the same day of month, or are on the last day of the month, the result
      is an exact numeric. Otherwise, the fraction is calculated base on 31
      days per month. You can cast the resulting value into INTERVAL MONTH and
      use it for datetime arithmetic. (HyperSQL)</p>
<pre class="programlisting"> VALUES MONTHS_BETWEEN ( TIMESTAMP '2013-02-14 12:30:44', TIMESTAMP '2012-01-04 12:30:44')

 C1                                  
 ----------------------------------- 
 13.32258064516129000000000000000000 
</pre>
<a name="N141D1" class="indexterm"></a>
<p>
<span class="bold"><strong>TIMESTAMPADD</strong></span>
</p>
<p>
<code class="literal">TIMESTAMPADD ( &lt;tsi datetime field&gt;, &lt;numeric
      value expression&gt;, &lt;datetime value expr&gt;)</code>
</p>
<a name="N141DD" class="indexterm"></a>
<p>
<span class="bold"><strong>TIMESTAMPDIFF</strong></span>
</p>
<p>
<code class="literal">TIMESTAMPDIFF ( &lt;tsi datetime field&gt;, &lt;datetime
      value expr 1&gt;, &lt;datetime value expr 2&gt;)</code>
</p>
<p>
<code class="literal">&lt;tsi datetime field&gt; ::= SQL_TSI_FRAC_SECOND |
      SQL_TSI_MILLI_SECOND | SQL_TSI_SECOND | SQL_TSI_MINUTE | SQL_TSI_HOUR |
      SQL_TSI_DAY | SQL_TSI_WEEK | SQL_TSI_MONTH | SQL_TSI_QUARTER |
      SQL_TSI_YEAR</code>
</p>
<p>HyperSQL supports full SQL Standard datetime features. It supports
      adding integers representing units of time directly to datetime values
      using the arithmetic plus operator. It also supports subtracting one
      <code class="literal">&lt;datetime value expr&gt;</code> from another in the given
      units of date or time using the minus operator. An example of
      <code class="literal">&lt;datetime value expr&gt; + &lt;numeric value expression&gt;
      &lt;datetime field&gt; </code>is <code class="literal">LOCALTIMESTAMP + 5
      DAY</code>. An example of <code class="literal">( &lt;datetime value expr&gt; -
      &lt;numeric value expression&gt; ) &lt;datetime field&gt; </code>is
      <code class="literal">(CURRENT_DATE - DATE '2008-08-8') MONTH </code>which returns
      the number of calendar months between the two dates.</p>
<p>The two JDBC functions, <code class="literal">TIMESTAMPADD </code>and
      <code class="literal">TIMESTAMPDIFF</code> perform a similar function to the above
      SQL expressions. The &lt;tsi datetime field&gt; names are keywords and
      are different from those used in the EXTRACT functions. These names are
      valid for use only when calling these two functions. With TIMESTAMPDIFF,
      the names indicate the unit of time used to compute the difference
      between two datetime fields. With TIMESTAMPADD they represent the unit
      of time used for the &lt;numeric value expression&gt;. The unit of time
      for each name is self-explanatory. In the case of SQL_TSI_FRAC_SECOND,
      the unit is nanosecond.</p>
<p>The return value for TIMESTAMPADD is of the same type as the
      datetime argument used. The return type for TIMESTAMPDIFF is always
      BIGINT, regardless of the type of arguments. The two datetime arguments
      of TIMESTAMPDIFF should be of the same type. The TIME type is not
      supported for the arguments to these functions.</p>
<p>
<code class="literal">TIMESTAMPDIFF</code> is evaluated as &lt;datetime
      value expr 2&gt; - &lt;datetime value expr 1&gt;. (JDBC)</p>
<pre class="programlisting"> TIMESTAMPADD ( SQL_TSI_MONTH, 3, DATE '2008-11-22' )

 TIMESTAMPDIFF ( SQL_TSI_HOUR, TIMESTAMP '2008-11-20 20:30:40', TIMESTAMP '2008-11-21 21:30:40' )
</pre>
<a name="N1420D" class="indexterm"></a>
<p>
<span class="bold"><strong>DATE_ADD</strong></span>
</p>
<p>
<code class="literal">DATE_ADD ( &lt;datetime value expr&gt; , &lt;interval
      value expr&gt; )</code>
</p>
<a name="N14219" class="indexterm"></a>
<p>
<span class="bold"><strong>DATE_SUB</strong></span>
</p>
<p>
<code class="literal">DATE_SUB ( &lt;datetime value expr&gt; , &lt;interval
      value expr&gt; )</code>
</p>
<p>These functions are equivalent to arithmetic addition and
      subtraction, &lt;datetime value expr&gt; + &lt;interval value expr&gt;
      and &lt;datetime value expr&gt; - &lt;interval value expr&gt;. The
      functions are provided for compatibility with other databases. The
      supported interval units are the standard SQL interval unit listed in
      other chapters of this guide. The TIME type is supported for the
      argument to these functions. (HyperSQL)</p>
<pre class="programlisting"> DATE_ADD ( DATE '2008-11-22', INTERVAL 3 MONTH )

 DATE_SUB ( TIMESTAMP '2008-11-22 20:30:40', INTERVAL 20 HOUR )
</pre>
<a name="N14229" class="indexterm"></a>
<p>
<span class="bold"><strong>DATEADD</strong></span>
</p>
<p>
<code class="literal">DATEADD ( &lt;field&gt;, &lt;numeric value expr&gt;,
      &lt;datetime value expr&gt; )</code>
</p>
<a name="N14235" class="indexterm"></a>
<p>
<span class="bold"><strong>DATEDIFF</strong></span>
</p>
<p>
<code class="literal">DATEDIFF ( &lt;field&gt;, &lt;datetime value expr 1&gt;,
      &lt;datetime value expr 2&gt; )</code>
</p>
<p>
<code class="literal">&lt;field&gt; ::= 'yy' | 'year' | 'mm' | 'month' | 'dd' |
      'day' | 'hh' | 'hour' | 'mi' | 'minute' | 'ss' | 'second' | 'ms' |
      'millisecond'</code>
</p>
<p>
<code class="literal">&lt;field&gt; ::= YY | YEAR | MM | MONTH | DD | DAY | HH
      | HOUR | MI | MINUTE | SS | SECOND | MS | MILLISECOND</code>
</p>
<p>The DATEADD and DATEDIFF functions are alternatives to
      TIMESTAMPADD and TIMESTAMPDIFF, with fewer available field options. The
      field names are specified as strings or as keywords. The short field
      names translate to YEAR, MONTH, DAY, HOUR, MINUTE, SECOND and
      MILLISECOND. <code class="literal">DATEDIFF</code> is evaluated as &lt;datetime
      value expr 2&gt; - &lt;datetime value expr 1&gt;. (HyperSQL}</p>
<p>
<code class="literal">DATEDIFF ( &lt;datetime value expr 1&gt;, &lt;datetime
      value expr 2&gt; )</code>
</p>
<p>This special form of <code class="literal">DATEDIFF</code> does not have a
      field parameter and return the number of days between two dates. This
      form is evaluated as <code class="literal">&lt;datetime value expr 1&gt; -
      &lt;datetime value expr 2&gt;</code>, which is different from the
      main form. This form is compatible with some other database engines. The
      TIME type is not supported for the arguments to these functions.
      (HyperSQL}</p>
<pre class="programlisting"> DATEADD ( 'month', 3, DATE '2008-11-22' )

 DATEDIFF ( 'hour', TIMESTAMP '2008-11-22 20:30:40', TIMESTAMP '2008-11-22 00:30:40' )
</pre>
<a name="N14259" class="indexterm"></a>
<p>
<span class="bold"><strong>ROUND</strong></span>
</p>
<p>
<code class="literal">ROUND ( &lt;datetime value expr&gt; [ , &lt;char value
      expr&gt; ] ) </code>
</p>
<p>The <code class="literal">&lt;datetime value expr&gt; </code>is of DATE,
      TIME or TIMESTAMP type. The <code class="literal">&lt;char value expr&gt;</code>
      is a format string for YEAR, MONTH, WEEK OF YEAR, DAY, HOUR, MINUTE or
      SECOND as listed in the table for TO_CHAR and TO_DATE format elements
      (see below). The datetime value is rounded up or down after the
      specified field and the rest of the fields to the right are set to one
      for MONTH and DAY, or zero, for the rest of the fields. For example
      rounding a timestamp value on the DAY field results in midnight the same
      date or midnight the next day if the time is at or after 12 noon. If the
      second argument is omitted, the datetime value is rounded to the nearest
      day. (HyperSQL)</p>
<a name="N1426D" class="indexterm"></a>
<p>
<span class="bold"><strong>TRUNC</strong></span>
</p>
<p>
<code class="literal">TRUNC ( &lt;datetime value expr&gt; [ , &lt;char value
      expr&gt; ] ) </code>
</p>
<p>Similar to the ROUND function, the <code class="literal">&lt;num value expr&gt;
      </code>is of DATE, TIME or TIMESTAMP type. The <code class="literal">&lt;char
      value expr&gt;</code> is a format string (such as 'YY' or 'MM') for
      YEAR, MONTH, WEEK OF YEAR, DAY, HOUR, MINUTE or SECOND as listed in the
      table for TO_CHAR and TO_DATE format elements (see below). The datetime
      value is truncated after the specified field and the rest of the fields
      to the right are set to one for MONTH and DAY, or zero, for the rest of
      the fields. For example applying TRUNC to a timestamp value on the DAY
      field results in midnight the same date. Examples of ROUND and TRUNC
      functions are given below. If the second argument is omitted, the
      datetime value is truncated to midnight the same date. (HyperSQL)</p>
<pre class="programlisting"> ROUND ( TIMESTAMP'2008-08-01 20:30:40', 'YYYY' )

 TIMESTAMP '2009-01-01 00:00:00'

 TRUNC ( TIMESTAMP'2008-08-01 20:30:40', 'YYYY' )

 TIMESTAMP '2008-01-01 00:00:00'
</pre>
</div>
<div class="section" title="Functions to Convert or Format a Datetime">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="bfc_datetime_format"></a>Functions to Convert or Format a Datetime</h3>
</div>
</div>
</div>
<a name="N14287" class="indexterm"></a>
<p>
<span class="bold"><strong>TIMESTAMP</strong></span>
</p>
<p>TIMESTAMP ( &lt;num value expr&gt; )</p>
<p>TIMESTAMP ( &lt;char value expr&gt; )</p>
<p>
<code class="literal">TIMESTAMP ( &lt;char value expr&gt;, &lt;char value
      expr&gt; )</code>
</p>
<p>
<code class="literal">TIMESTAMP ( &lt;date value expr&gt;, &lt;time value
      expr&gt; )</code>
</p>
<p>This function translates the arguments into a TIMESTAMP WIHOUT
      TIME ZONE value.</p>
<p>When the single argument is a numeric value, it is interpreted as
      a Unix timestamp in seconds.</p>
<p>When the single argument is a formatted date or timestamp string,
      it is translated to a TIMESTAMP.</p>
<p>When two arguments are used, the first argument is the date part
      and the second argument is the time part of the returned TIMESTAMP
      value. An example, including the result, is given below:</p>
<pre class="programlisting"> TIMESTAMP ( '2008-11-22', '20:30:40' )

 TIMESTAMP '2008-11-22 20:30:40.000000'
</pre>
<a name="N142A4" class="indexterm"></a>
<p>
<span class="bold"><strong>TIMESTAMP_WITH_ZONE</strong></span>
</p>
<p>TIMESTAMP_WITH_ZONE ( &lt;num value expr&gt; )</p>
<p>TIMESTAMP_WITH_ZONE ( &lt;char value expr&gt; )</p>
<p>This function translates the arguments into a TIMESTAMP WITH TIME
      ZONE value.</p>
<p>When the single argument is a numeric value, it is interpreted as
      a Unix timestamp in seconds.</p>
<p>When the single argument is TIMESTAMP, it is converted to
      TIMESTAMP WITH TIME ZONE.</p>
<p>The time zone of the returned value is the local time zone at the
      time of the timestamp argument. This accounts for daylight saving times.
      For example, if the local time zone was +4:00 at the time of the given
      Unix timestamp, the returned value is local timestamp at the time with
      time zone +4:00.</p>
<a name="N142B9" class="indexterm"></a>
<p>
<span class="bold"><strong>TO_CHAR</strong></span>
</p>
<p>
<code class="literal">TO_CHAR ( &lt;datetime value expr&gt;, &lt;char value
      expr&gt; )</code>
</p>
<p>This function formats a datetime or numeric value to the format
      given in the second argument. The format string can contain pattern
      elements from the list given below, plus punctuation and space
      characters. An example, including the result, is given below:</p>
<pre class="programlisting"> TO_CHAR ( TIMESTAMP'2008-02-01 20:30:40', 'YYYY BC MONTH, DAY HH' )

 2008 AD February, Friday 8

 TO_CHAR ( TIMESTAMP'2008-02-01 20:30:40', '"The Date is" YYYY BC MONTH, DAY HH' )

 The Date is 2008 AD February, Friday 8
</pre>
<p>The format is internally translated to a
      <code class="classname">java.text.SimpleDateFormat</code> format string.
      Separator characters (space, comma, period, hyphen, colon, semicolon,
      forward slash) can be included between the pattern elements. Unsupported
      format strings should not be used. You can include a string literal
      inside the format string by enclosing it in double quotes (see the
      second example above). (HyperSQL)</p>
<a name="N142CE" class="indexterm"></a>
<p>
<span class="bold"><strong>TO_DATE</strong></span>
</p>
<p>
<code class="literal">TO_DATE ( &lt;char value expr&gt;, &lt;char value
      expr&gt; )</code>
</p>
<p>This function translates a formatted datetime sting to a
      TIMESTAMP(0) according to the format given in the second argument. See
      TO_TIMESTAMP below for further details.</p>
<a name="N142DC" class="indexterm"></a>
<p>
<span class="bold"><strong>TO_TIMESTAMP</strong></span>
</p>
<p>
<code class="literal">TO_TIMESTAMP ( &lt;char value expr&gt;, &lt;char value
      expr&gt; )</code>
</p>
<p>This function translates a formatted datetime sting to a
      TIMESTAMP(6) according to the format given in the second argument. The
      format string can contain pattern elements from the list given below,
      plus punctuation and space characters. The pattern should contain all
      the necessary fields to construct a date, including, year, month, day of
      month, etc. The returned timestamp can then be cast into DATE or TIME
      types if necessary. An example, including the result, is given
      below:</p>
<pre class="programlisting"> TO_TIMESTAMP ( '22/11/2008 20:30:40', 'DD/MM/YYYY HH:MI:SS' )

 TIMESTAMP '2008-11-22 20:30:40.000000'
</pre>
<p>The format strings that can be used for TO_DATE and TO_TIMESTAMP
      are more restrictive than those used for TO_CHAR, because the format
      string must contain the elements needed to build a full DATE or
      TIMESTAMP value. For example, you cannot use the 'WW', 'W', 'HH' or
      'HH12' format elements with TO_DATE or TO_TIMESTAMP</p>
<p>The format is internally translated to a
      <code class="classname">java.text.SimpleDateFormat</code> format string.
      Unsupported format strings should not be used. With TO_CHAR, you can
      include a string literal inside the format string by enclosing it in
      double quotes. (HyperSQL)</p>
<p>The supported format components are all uppercase as
      follows:</p>
<div class="table">
<a name="N142F5"></a>
<p class="title">
<b>Table&nbsp;10.1.&nbsp;TO_CHAR, TO_DATE and TO_TIMESTAMP format elements</b>
</p>
<div class="table-contents">
<table summary="TO_CHAR, TO_DATE and TO_TIMESTAMP format elements" cellspacing="0" style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; border-left: 0.5pt solid ; border-right: 0.5pt solid ; ">
<colgroup>
<col width="5cm">
<col>
</colgroup>
<tbody>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">BC | B.C. | AD | A.D.</code></td><td style="border-bottom: 0.5pt solid ; ">Returns <code class="literal">AD</code> for common era and
              <code class="literal">BC</code> for before common era</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">RRRR</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>4-digit year</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">YYYY</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>4-digit year</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">IYYY</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>4-digit year, corresponding to ISO week of the
              year. The reported year for the last few days of the calendar
              year may be the next year.</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">YY</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>2 digit year</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">IY</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>2 digit year, corresponding to ISO week of the year
              </p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">MM</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Month (01-12)</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">MON</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Short three-letter name of month</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">MONTH</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Name of month</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">WW</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Week of year (1-53) where week 1 starts on the
              first day of the year and continues to the seventh day of the
              year (not a calendar week).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">W</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Week of month (1-5) where week 1 starts on the
              first day of the month and ends on the seventh (not a calendar
              week).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">IW</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Week of year (1-52 or 1-53) based on the ISO
              standard. Week starts on Monday. The first week may start near
              the end of previous year.</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">DAY</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Name of day.</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">DD</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Day of month (01-31).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">DDD</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Day of year (1-366).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">DY</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Short three-letter name of day.</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">HH</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Hour of day (00-11).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">HH12</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Hour of day (00-11).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">HH24</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Hour of day (00-23).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">MI</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Minute (00-59).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; "><code class="literal">SS</code></td><td style="border-bottom: 0.5pt solid ; ">
<p>Second (00-59).</p>
</td>
</tr>
<tr>
<td style="border-right: 0.5pt solid ; "><code class="literal">FF</code></td><td style="">
<p>Fractional seconds.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break">
</div>
</div>
<div class="section" title="Array Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_array_functions"></a>Array Functions</h2>
</div>
</div>
</div>
<p>Array functions are specialised functions with ARRAY parameters or
    return values. For the ARRAY_AGG aggregate function, see the <a class="link" href="dataaccess-chapt.html" title="Chapter&nbsp;7.&nbsp;Data Access and Change">Data Access and Change</a>
    chapter.</p>
<a name="N143AA" class="indexterm"></a>
<p>
<span class="bold"><strong>CARDINALITY</strong></span>
</p>
<p>
<code class="literal">CARDINALITY( &lt;array value expr&gt; )</code>
</p>
<p>Returns the element count for the given array argument.
    (Foundation)</p>
<a name="N143B8" class="indexterm"></a>
<p>
<span class="bold"><strong>MAX_CARDINALITY</strong></span>
</p>
<p>
<code class="literal">MAX_CARDINALITY( &lt;array value expr&gt;
    )</code>
</p>
<p>Returns the maximum allowed element count for the given array
    argument. (Foundation)</p>
<a name="N143C6" class="indexterm"></a>
<p>
<span class="bold"><strong>POSITION_ARRAY</strong></span>
</p>
<p>
<code class="literal">POSITION_ARRAY( &lt;value expression&gt; IN &lt;array value
    expr&gt; [ FROM &lt;int value expr&gt; ] )</code>
</p>
<p>Returns the position of the first match for the <code class="literal">&lt;value
    expression&gt;</code> in the array. By default the search starts from
    the beginning of the array. The optional <code class="literal">&lt;int value
    expr&gt;</code> specifies the start position. Positions are counted
    from 1. Returns zero if no match is found. (HyperSQL)</p>
<a name="N143DA" class="indexterm"></a>
<p>
<span class="bold"><strong>SORT_ARRAY</strong></span>
</p>
<p>
<code class="literal">SORT_ARRAY( &lt;array value expr&gt; [ { ASC | DESC } ] [
    NULLS { FIRST | LAST } ] )</code>
</p>
<p>Returns a sorted copy of the array. By default, sort is performed in
    ascending order and NULL elements are sorted first. (HyperSQL)</p>
<a name="N143E8" class="indexterm"></a>
<p>
<span class="bold"><strong>TRIM_ARRAY</strong></span>
</p>
<p>
<code class="literal">TRIM_ARRAY( &lt;array value expr&gt;, &lt;num value
    expr&gt; )</code>
</p>
<p>Returns a new array that contains the elements of the
    <code class="literal">&lt;array value expr&gt;</code> minus the number of elements
    specified by the <code class="literal">&lt;num value expr&gt;. </code>Elements are
    discarded from the end of the array. (Foundation)</p>
<a name="N143FC" class="indexterm"></a>
<p>
<span class="bold"><strong>SEQUENCE_ARRAY</strong></span>
</p>
<p>
<code class="literal">SEQUENCE_ARRAY( &lt;value expr 1&gt;, &lt;value expr 2&gt;,
    &lt;value expr 3 )</code>
</p>
<p>Returns a new array that contains a sequence of values. The
    <code class="literal">&lt;value expr 1&gt;</code> is the lower bound of the range.
    The <code class="literal">&lt;value expr 2&gt;</code> is the upper bound of the
    range. The <code class="literal">&lt;value expr 3&gt;</code> is the increment. The
    elments of the array are within the inclusive range. The first element is
    <code class="literal">&lt;value expr 1&gt;</code> and each subsequent element is the
    sum of the previous element and the increment. If the increment is zero,
    only the first element is returned. When the increment is negative, the
    lower bound should be larger than the upper bound. The type of the
    arguments can be all number types, or a datetime range and an interval for
    the third argument (HyperSQL)</p>
<p>In the examples below, a number sequence and a date sequence are
    shown. The UNNEST table expression is used to form a table from the
    array.</p>
<pre class="programlisting"> SEQUENCE_ARRAY(0, 100, 5)

 ARRAY[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100] 

 SELECT * FROM UNNEST(SEQUENCE_ARRAY(10, 12, 1))

 C1 
 -- 
 10 
 11 
 12 

 SELECT * FROM UNNEST(SEQUENCE_ARRAY(CURRENT_DATE, CURRENT_DATE + 6 DAY, 1 DAY)) WITH ORDINALITY AS T(D, I) 

 D          I 
 ---------- - 
 2010-08-01 1 
 2010-08-02 2 
 2010-08-03 3 
 2010-08-04 4 
 2010-08-05 5 
 2010-08-06 6 
 2010-08-07 7

</pre>
</div>
<div class="section" title="General Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_general_functions"></a>General Functions</h2>
</div>
</div>
</div>
<p>General functions can take different types of arguments. Some
    General Functions accept a variable number of arguments.</p>
<p>Also see the <a class="link" href="dataaccess-chapt.html" title="Chapter&nbsp;7.&nbsp;Data Access and Change">Data Access and Change</a> chapter for SQL expressions that
    are similar to functions, for example CAST and NULLIF.</p>
<a name="N14427" class="indexterm"></a>
<p>
<span class="bold"><strong>CASEWHEN</strong></span>
</p>
<p>
<code class="literal">CASEWHEN( &lt;boolean value expr&gt;, &lt;value expr 2&gt;,
    &lt;value expr 3&gt; )</code>
</p>
<p>If the <code class="literal">&lt;boolean value expr&gt;</code> is true,
    returns <code class="literal">&lt;value expr 2&gt;</code> otherwise returns
    <code class="literal">&lt;value expr 3&gt;. Use a CASE WHEN expression instead for more
    extensive capabilities and options.</code> CASE WHEN is documented in
    the <a class="link" href="dataaccess-chapt.html" title="Chapter&nbsp;7.&nbsp;Data Access and Change">Data Access and Change</a> chapter. (HyperSQL)</p>
<a name="N14443" class="indexterm"></a>
<p>
<span class="bold"><strong>COALESCE</strong></span>
</p>
<p>
<code class="literal">COALESCE( &lt;value expr 1&gt;, &lt;value expr 2&gt; [,
    ...] )</code>
</p>
<p>Returns <code class="literal">&lt;value expr 1&gt;</code> if it is not null,
    otherwise returns <code class="literal">&lt;value expr 2&gt;</code> if not null and
    so on. The type of both arguments must be comparable. (Foundation)</p>
<a name="N14457" class="indexterm"></a>
<p>
<span class="bold"><strong>CONVERT</strong></span>
</p>
<p>
<code class="literal">CONVERT ( &lt;value expr&gt; , &lt;data type&gt;
    )</code>
</p>
<p>
<code class="literal">&lt;data type&gt; ::= { SQL_BIGINT | SQL_BINARY | SQL_BIT
    |SQL_BLOB | SQL_BOOLEAN | SQL_CHAR | SQL_CLOB | SQL_DATE | SQL_DECIMAL |
    SQL_DATALINK |SQL_DOUBLE | SQL_FLOAT | SQL_INTEGER | SQL_LONGVARBINARY |
    SQL_LONGNVARCHAR | SQL_LONGVARCHAR | SQL_NCHAR | SQL_NCLOB | SQL_NUMERIC |
    SQL_NVARCHAR | SQL_REAL | SQL_ROWID | SQL_SQLXML | SQL_SMALLINT | SQL_TIME
    | SQL_TIMESTAMP | SQL_TINYINT | SQL_VARBINARY | SQL_VARCHAR} [ (
    &lt;precision, length or scale parameters&gt; ) ]</code>
</p>
<p>The CONVERT function is a JDBC escape function, equivalent to the
    SQL standard CAST expression. It converts the <code class="literal">&lt;value
    expr&gt;</code> into the given <code class="literal">&lt;data type&gt;</code> and
    returns the value. The <code class="literal">&lt;data type&gt;</code> options are
    synthetic names made by prefixing type names with <code class="literal">SQL_</code>.
    Some of the <code class="literal">&lt;data type&gt;</code> options represent valid
    SQL types, but some are based on non-standard type names, namely
    <code class="literal">{ SQL_LONGNVARCHAR | SQL_LONGVARBINARY |SQL_LONGVARCHAR |
    SQL_TINYINT }</code>. None of the synthetic names can be used in any
    other context than the CONVERT function.</p>
<p>The definition of CONVERT in the JDBC Standard does not allow the
    precision, scale or length to be specified. This is required by the SQL
    standard for BINARY, BIT, BLOB, CHAR, CLOB, VARBINARY and VARCHAR types
    and is often needed for DECIMAL and NUMERIC. Defaults are used for
    precision.</p>
<p>HyperSQL also allows the use of real type names (without the
    <code class="literal">SQL_</code> prefix). In this usage, HyperSQL allows the use of
    precision, scale or length for the type definition when they are valid for
    the type definition.</p>
<p>When MS SQL Server compatibility mode is on, the parameters of
    CONVERT are switched and only the real type names with required precision,
    scale or length are allowed. (JDBC)</p>
<a name="N14483" class="indexterm"></a>
<p>
<span class="bold"><strong>DECODE</strong></span>
</p>
<p>
<code class="literal">DECODE( &lt;value expr main&gt;, &lt;value expr match
    1&gt;, &lt;value expr result 1&gt; [...,] [, &lt;value expr default&gt;]
    )</code>
</p>
<p>DECODE takes at least 3 arguments. The <code class="literal">&lt;value expr
    main&gt;</code> is compared with <code class="literal">&lt;value expr match
    1&gt;</code> and if it matches, <code class="literal">&lt;value expr result
    1&gt;</code> is returned. If there are additional pairs of
    <code class="literal">&lt;value expr match n&gt;</code> and <code class="literal">&lt;value expr
    result n&gt;</code>, comparison is repeated until a match is found the
    result is returned. If no match is found, the <code class="literal">&lt;value expr
    default&gt;</code> is returned if it is specified, otherwise NULL is
    returned. The type of the return value is a combination of the types of
    the <code class="literal">&lt;value expr result ... &gt;</code> arguments.
    (HyperSQL)</p>
<a name="N144A6" class="indexterm"></a>
<p>
<span class="bold"><strong>GREATEST</strong></span>
</p>
<p>
<code class="literal">GREATEST( &lt;value expr 1&gt;, [&lt;value expr ...&gt;,
    ...] )</code>
</p>
<p>The GREATEST function takes one or more arguments. It compares the
    arguments with each other and returns the greatest argument. The return
    type is the combined type of the arguments. Arguments can be of any type,
    so long as they are comparable. (HyperSQL)</p>
<a name="N144B4" class="indexterm"></a>
<p>
<span class="bold"><strong>IFNULL</strong></span>
</p>
<a name="N144BD" class="indexterm"></a>
<p>
<span class="bold"><strong>ISNULL</strong></span>
</p>
<p>
<code class="literal">IFNULL | ISNULL ( &lt;value expr 1&gt;, &lt;value expr
    2&gt; )</code>
</p>
<p>Returns <code class="literal">&lt;value expr 1&gt;</code> if it is not null,
    otherwise returns <code class="literal">&lt;value expr 2&gt;</code>. The type of the
    return value is the type of <code class="literal">&lt;value expr 1&gt;</code>.
    Almost equivalent to SQL Standard <code class="literal">COALESCE(&lt;value expr 1&gt;,
    &lt;value expr 2&gt;)</code> function, but without type modification.
    (JDBC)</p>
<a name="N144D7" class="indexterm"></a>
<p>
<span class="bold"><strong>LEAST</strong></span>
</p>
<p>
<code class="literal">LEAST( &lt;value expr 1&gt;, [&lt;value expr ...&gt;, ...]
    )</code>
</p>
<p>The LEAST function takes one or more arguments. It compares the
    arguments with each other and returns the smallest argument. The return
    type is the combined type of the arguments. Arguments can be of any type,
    so long as they are comparable. (HyperSQL)</p>
<a name="N144E5" class="indexterm"></a>
<p>
<span class="bold"><strong>LOAD_FILE</strong></span>
</p>
<p>
<code class="literal">LOAD_FILE ( &lt;char value expr 1&gt; [, &lt;char value
    expr 2&gt;] )</code>
</p>
<p>Returns a BLOB or CLOB containing the URL or file path specified in
    the first argument. If used with a single argument, the function returns a
    BLOB. If used with two arguments, the function returns a CLOB and the
    second argument is the character encoding of the file.</p>
<p>The file path is interpreted the same way as a TEXT TABLE source
    file location. The <code class="literal">hsqldb.allow_full_path</code> system
    property must be set <code class="literal">true</code> in order to access files
    outside the directory structure of the database files.</p>
<p>(HyperSQL)</p>
<a name="N144FD" class="indexterm"></a>
<p>
<span class="bold"><strong>NULLIF</strong></span>
</p>
<p>
<code class="literal">NULLIF( &lt;value expr 1&gt;, &lt;value expr 2&gt;
    )</code>
</p>
<p>Returns <code class="literal">&lt;value expr 1&gt;</code> if it is not equal
    to <code class="literal">&lt;value expr 2&gt;</code>, otherwise returns null. The
    type of both arguments must be the same. This function is a shorthand for
    a specific CASE expression. (Foundation)</p>
<a name="N14511" class="indexterm"></a>
<p>
<span class="bold"><strong>NVL</strong></span>
</p>
<p>
<code class="literal">NVL( &lt;value expr 1&gt;, &lt;value expr 2&gt;
    )</code>
</p>
<p>Returns <code class="literal">&lt;value expr 1&gt;</code> if it is not null,
    otherwise returns <code class="literal">&lt;value expr 2&gt;</code>. The type of the
    return value is the type of <code class="literal">&lt;value expr 1&gt;</code>. For
    example, if <code class="literal">&lt;value expr 1&gt;</code> is an INTEGER column
    and <code class="literal">&lt;value expr 2&gt;</code> is a DOUBLE constant, the
    return type is cast into INTEGER. This function is similar to IFNULL.
    (HyperSQL)</p>
<a name="N1452E" class="indexterm"></a>
<p>
<span class="bold"><strong>NVL2</strong></span>
</p>
<p>
<code class="literal">NVL2( &lt;value expr 1&gt;, &lt;value expr 2&gt;, &lt;value
    expr 3&gt; )</code>
</p>
<p>If <code class="literal">&lt;value expr 1&gt;</code> is not null, returns
    <code class="literal">&lt;value expr 2&gt;</code>, otherwise returns
    <code class="literal">&lt;value expr 3&gt;</code>. The type of the return value is
    the type of <code class="literal">&lt;value expr 2&gt;</code> unless it is null.
    (HyperSQL)</p>
<a name="N14548" class="indexterm"></a>
<p>
<span class="bold"><strong>UUID</strong></span>
</p>
<p>
<code class="literal">UUID ( [ { &lt;char value expr&gt; | &lt;binary value
    expr&gt; ] } ) </code>
</p>
<p>With no parameter, this function returns a new UUID value as a 16
    byte binary value. With a UUID hexadecimal string argument, it returns the
    16 byte binary value of the UUID. With a 16 byte binary argument, it
    returns the formatted UUID character representation. (HyperSQL)</p>
<p>
<span class="bold"><strong>SYS_GUID</strong></span>
</p>
<p>
<code class="literal">SYS_GUID () </code>
</p>
<p>
<span class="bold"><strong>NEWID</strong></span>
</p>
<p>
<code class="literal">NEWID () </code>
</p>
<p>These are synonyms for the UUID function in ORA and MSS
    compatibility modes. (HyperSQL)</p>
</div>
<div class="section" title="System Functions">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="bfc_system_functions"></a>System Functions</h2>
</div>
</div>
</div>
<a name="N1456A" class="indexterm"></a>
<p>
<span class="bold"><strong>CRYPT_KEY</strong></span>
</p>
<p>
<code class="literal">CRYPT_KEY( &lt;value expr 1&gt;, &lt;value expr 2&gt;
    )</code>
</p>
<p>Returns a binary string representation of a cryptography key for the
    given cipher and cryptography provider. The cipher specification is
    specified by <code class="literal">&lt;value expr 1&gt;</code> and the provider by
    <code class="literal">&lt;value expr 2&gt;</code>. To use the default provider,
    specify null for <code class="literal">&lt;value expr 2&gt;</code>.
    (HyperSQL)</p>
<a name="N14581" class="indexterm"></a>
<p>
<span class="bold"><strong>DIAGNOSTICS</strong></span>
</p>
<p>
<code class="literal">DIAGNOSTICS ( ROW_COUNT )</code>
</p>
<p>This is a convenience function for use instead of the <code class="literal">GET
    DIAGNOSTICS ...</code> statement. The argument specifies the name of
    the diagnostics variable. Currently the only supported variable is the
    <code class="literal">ROW_COUNT</code> variable. The function returns the row count
    returned by the last executed statement. The return value is 0 after most
    statements. Calling this function immediately after executing an INSERT,
    UPDATE, DELETE or MERGE statement returns the row count for the last
    statement, as it is returned by the JDBC statement. (HyperSQL)</p>
<a name="N14595" class="indexterm"></a>
<p>
<span class="bold"><strong>IDENTITY</strong></span>
</p>
<p>
<code class="literal">IDENTITY ()</code>
</p>
<p>Returns the last IDENTITY value inserted into a row by the current
    session. The statement, CALL IDENTITY() can be made after an INSERT
    statement that inserts a row into a table with an IDENTITY column. The
    CALL IDENTITY() statement returns the last IDENTITY value that was
    inserted into a table by the current session. Each session manages this
    function call separately and is not affected by inserts in other sessions.
    The statement can be executed as a direct statement or a prepared
    statement. (HyperSQL)</p>
<a name="N145A3" class="indexterm"></a>
<p>
<span class="bold"><strong>DATABASE</strong></span>
</p>
<p>
<code class="literal">DATABASE ()</code>
</p>
<p>Returns the file name (without directory information) of the
    database. (JDBC)</p>
<a name="N145B1" class="indexterm"></a>
<p>
<span class="bold"><strong>DATABASE_NAME</strong></span>
</p>
<p>
<code class="literal">DATABASE_NAME ()</code>
</p>
<p>Returns the database name. This name is a 16 character, uppercase
    string. It is generated as a string based on the timestamp of the creation
    of the database, for example HSQLDB32438AEAFB. The name can be redefined
    by an admin user but the new name must be all uppercase and 16 characters
    long. This name is used in log messages with external logging frameworks.
    (HyperSQL)</p>
<a name="N145BF" class="indexterm"></a>
<p>
<span class="bold"><strong>DATABASE_VERSION</strong></span>
</p>
<p>
<code class="literal">DATABASE_VERSION ()</code>
</p>
<p>Returns the full version string for the database engine. For
    example, 2.0.1. (JDBC)</p>
<a name="N145CD" class="indexterm"></a>
<p>
<span class="bold"><strong>USER</strong></span>
</p>
<p>
<code class="literal">USER ()</code>
</p>
<p>Equivalent to the SQL function <code class="literal">CURRENT_USER</code>.
    (JDBC)</p>
<a name="N145DE" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_USER</strong></span>
</p>
<p>
<code class="literal">CURRENT_USER</code>
</p>
<a name="N145EA" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_ROLE</strong></span>
</p>
<p>
<code class="literal">CURRENT_ROLE</code>
</p>
<a name="N145F6" class="indexterm"></a>
<p>
<span class="bold"><strong>SESSION_USER</strong></span>
</p>
<p>
<code class="literal">SESSION_USER</code>
</p>
<a name="N14602" class="indexterm"></a>
<p>
<span class="bold"><strong>SYSTEM_USER</strong></span>
</p>
<p>
<code class="literal">SYSTEM_USER</code>
</p>
<a name="N1460E" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_SCHEMA</strong></span>
</p>
<p>
<code class="literal">CURRENT_SCHEMA</code>
</p>
<a name="N1461A" class="indexterm"></a>
<p>
<span class="bold"><strong>CURRENT_CATALOG</strong></span>
</p>
<p>
<code class="literal">CURRENT_CATALOG</code>
</p>
<p>These functions return the named current session attribute. They are
    all SQL Standard functions.</p>
<p>The CURRENT_USER is the user that connected to the database, or a
    user subsequently set by the SET AUTHORIZATION statement.</p>
<p>SESSION_USER is the same as CURRENT_USER</p>
<p>SYSTEM_USER is the user that connected to the database. It is not
    changed with any command until the session is closed.</p>
<p>CURRENT_SCHEMA is default schema of the user, or a schema
    subsequently set by the SET SCHEMA command.</p>
<p>CURRENT_CATALOG is always the same within a given HyperSQL database
    and indicates the name of the catalog.</p>
<a name="N14632" class="indexterm"></a>
<p>
<span class="bold"><strong>IS_AUTOCOMMIT</strong></span>
</p>
<p>
<code class="literal">IS_AUTOCOMMIT()</code>
</p>
<p>Returns TRUE if the session is in autocommit mode. (HyperSQL)</p>
<a name="N14640" class="indexterm"></a>
<p>
<span class="bold"><strong>IS_READONLY_SESSION</strong></span>
</p>
<p>
<code class="literal">IS_READONLY_SESSION()</code>
</p>
<p>Returns TRUE if the session is in read only mode. (HyperSQL)</p>
<a name="N1464E" class="indexterm"></a>
<p>
<span class="bold"><strong>IS_READONLY_DATABASE</strong></span>
</p>
<p>
<code class="literal">IS_READONLY_DATABASE()</code>
</p>
<p>Returns TRUE if the database is a read only database.
    (HyperSQL)</p>
<a name="N1465C" class="indexterm"></a>
<p>
<span class="bold"><strong>IS_READONLY_DATABASE_FILES</strong></span>
</p>
<p>
<code class="literal">IS_READONLY_DATABASE_FILES()</code>
</p>
<p>Returns TRUE if the database is a read-only files database. In this
    kind of database, it is possible to modify the data, but the changes are
    not persisted to the database files. (HyperSQL)</p>
<a name="N1466A" class="indexterm"></a>
<p>
<span class="bold"><strong>ISOLATION_LEVEL</strong></span>
</p>
<p>
<code class="literal">ISOLATION_LEVEL()</code>
</p>
<p>Returns the current transaction isolation level for the session.
    Returns either READ COMMITTED or SERIALIZABLE as a string.
    (HyperSQL)</p>
<a name="N14678" class="indexterm"></a>
<p>
<span class="bold"><strong>SESSION_ID</strong></span>
</p>
<p>
<code class="literal">SESSION_ID()</code>
</p>
<p>Returns the id of the session as a BIGINT value. Each session id is
    unique during the operational lifetime of the database. Id's are restarted
    after a shutdown and restart. (HyperSQL)</p>
<a name="N14686" class="indexterm"></a>
<p>
<span class="bold"><strong>SESSION_ISOLATION_LEVEL</strong></span>
</p>
<p>
<code class="literal">SESSION_ISOLATION_LEVEL()</code>
</p>
<p>Returns the default transaction isolation level for the current
    session. Returns either READ COMMITTED or SERIALIZABLE as a string.
    (HyperSQL)</p>
<a name="N14694" class="indexterm"></a>
<p>
<span class="bold"><strong>DATABASE_ISOLATION_LEVEL</strong></span>
</p>
<p>
<code class="literal">DATABASE_ISOLATION_LEVEL()</code>
</p>
<p>Returns the default transaction isolation level for the database.
    Returns either READ COMMITTED or SERIALIZABLE as a string.
    (HyperSQL)</p>
<a name="N146A2" class="indexterm"></a>
<p>
<span class="bold"><strong>TRANSACTION_SIZE</strong></span>
</p>
<p>
<code class="literal">TRANSACTION_SIZE()</code>
</p>
<p>Returns the row change count for the current transaction. Each row
    change represents a row INSERT or a row DELETE operation. There will be a
    pair of row change operations for each row that is updated.</p>
<a name="N146B0" class="indexterm"></a>
<p>
<span class="bold"><strong>TRANSACTION_ID</strong></span>
</p>
<p>
<code class="literal">TRANSACTION_ID()</code>
</p>
<p>Returns the current transaction ID for the session as a BIGINT
    value. The database maintains a global incremental id which is allocated
    to new transactions and new actions (statement executions) in different
    sessions. This value is unique to the current transaction.
    (HyperSQL)</p>
<a name="N146BE" class="indexterm"></a>
<p>
<span class="bold"><strong>ACTION_ID</strong></span>
</p>
<p>
<code class="literal">ACTION_ID()</code>
</p>
<p>Returns the current action ID for the session as a BIGINT value. The
    database maintains a global incremental id which is allocated to new
    transactions and new actions (statement executions) in different sessions.
    This value is unique to the current action. (HyperSQL)</p>
<a name="N146CC" class="indexterm"></a>
<p>
<span class="bold"><strong>TRANSACTION_CONTROL</strong></span>
</p>
<p>
<code class="literal">TRANSACTION_CONTROL()</code>
</p>
<p>Returns the current transaction model for the database. Returns
    LOCKS, MVLOCKS or MVCC as a string. (HyperSQL)</p>
<a name="N146DA" class="indexterm"></a>
<p>
<span class="bold"><strong>LOB_ID</strong></span>
</p>
<p>
<code class="literal">LOB_ID( &lt;column reference&gt; )</code>
</p>
<p>Returns internal ID of a lob as a BIGINT value. Lob ID's are unique
    and never reused. The &lt;column reference&gt; is the name of the column
    (or variable, or argument) which is a CLOB or BLOB. Returns null if the
    value is null. (HyperSQL)</p>
<a name="N146E8" class="indexterm"></a>
<p>
<span class="bold"><strong>ROWNUM</strong></span>
</p>
<p>
<code class="literal">ROWNUM()</code>
</p>
<a name="N146F4" class="indexterm"></a>
<p>
<span class="bold"><strong>ROW_NUMBER</strong></span>
</p>
<p>
<code class="literal">ROW_NUMBER() OVER()</code>
</p>
<p>Returns the current row number (from 1) being processed in a select
    statement. This has the same semantics as the ROWNUM pseudo-column in ORA
    syntax mode, but can be used in any syntax mode. The function is used in a
    SELECT or DELETE statement. The ROWNUM of a row is incremented as the rows
    are added to the result set. It is therefore possible to use a condition
    such as WHERE ROWNUM() &lt; 10, but not ROWNUM() &gt; 10 or ROWNUM = 10.
    The <code class="literal">ROW_NUMBER() OVER()</code> alternative performs the same
    function and is included for compatibility with other database
    engines.(HyperSQL)</p>
</div>
</div>
<HR xmlns:xi="http://www.w3.org/2001/XInclude">
<P xmlns:xi="http://www.w3.org/2001/XInclude" class="svnrev">$Revision: 5675 $</P>
<div class="navfooter">
<hr>
<table summary="Navigation footer" width="100%">
<tr>
<td align="left" width="40%"><a accesskey="p" href="triggers-chapt.html"><img src="../images/db/prev.png" alt="Prev"></a>&nbsp;</td><td align="center" width="20%">&nbsp;</td><td align="right" width="40%">&nbsp;<a accesskey="n" href="management-chapt.html"><img src="../images/db/next.png" alt="Next"></a></td>
</tr>
<tr>
<td valign="top" align="left" width="40%">Chapter&nbsp;9.&nbsp;Triggers&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html"><img src="../images/db/home.png" alt="Home"></a></td><td valign="top" align="right" width="40%">&nbsp;Chapter&nbsp;11.&nbsp;System Management</td>
</tr>
</table>
</div>
</body>
</html>