ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafyspecifycurdate.htm

58 lines
4.0 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Specify current date and time values" />
<meta name="abstract" content="You can specify a current date, time, or timestamp in an expression by specifying one of three special registers: CURRENT DATE, CURRENT TIME, or CURRENT TIMESTAMP." />
<meta name="description" content="You can specify a current date, time, or timestamp in an expression by specifying one of three special registers: CURRENT DATE, CURRENT TIME, or CURRENT TIMESTAMP." />
<meta name="DC.subject" content="SELECT statement, date value, time value, timestamp value, statements, date value, time value, date format, time format, timestamp format, examples, CURRENT DATE, special register, CURRENT TIMEZONE" />
<meta name="keywords" content="SELECT statement, date value, time value, timestamp value, statements, date value, time value, date format, time format, timestamp format, examples, CURRENT DATE, special register, CURRENT TIMEZONE" />
<meta name="DC.Relation" scheme="URI" content="rbafydtts.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafyspecifycurdate" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Specify current date and time values</title>
</head>
<body id="rbafyspecifycurdate"><a name="rbafyspecifycurdate"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Specify current date and time values</h1>
<div><p>You can specify a current date, time, or timestamp in an expression
by specifying one of three special registers: CURRENT DATE, CURRENT TIME,
or CURRENT TIMESTAMP.</p>
<div class="section"><p>The value of each is based on a time-of-day clock reading obtained
during the running of the statement. Multiple references to CURRENT DATE,
CURRENT TIME, or CURRENT TIMESTAMP within the same SQL statement use the same
value. The following statement returns the age (in years) of each employee
in the EMPLOYEE table when the statement is run:</p>
<pre> <strong>SELECT YEAR</strong>(<strong>CURRENT DATE</strong> - BIRTHDATE)
<strong>FROM</strong> CORPDATA.EMPLOYEE</pre>
</div>
<div class="section"><p>The CURRENT TIMEZONE special register allows a local time to be
converted to Universal Time Coordinated (UTC). For example, if you have a
table named DATETIME, containing a time column type with a name of STARTT,
and you want to convert STARTT to UTC, you can use the following statement:</p>
<pre> <strong>SELECT</strong> STARTT - <strong>CURRENT TIMEZONE</strong>
<strong>FROM</strong> DATETIME</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafydtts.htm" title="Date, time, and timestamp are data types represented in an internal form not seen by the SQL user.">Date, time, and timestamp data types</a></div>
</div>
</div>
</body>
</html>