ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzate_5.4.0.1/rzatecurdateex.htm

54 lines
3.2 KiB
HTML
Raw Permalink 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="topic" />
<meta name="DC.Title" content="Example: Select records based on the current date" />
<meta name="abstract" content="This example illustrates how to select records from a table based on the current date." />
<meta name="description" content="This example illustrates how to select records from a table based on the current date." />
<meta name="copyright" content="(C) Copyright IBM Corporation 2004, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2004, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzatecurdateex" />
<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>Example: Select records based on the current date</title>
</head>
<body id="rzatecurdateex"><a name="rzatecurdateex"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Select records based on the current date</h1>
<div><p>This example illustrates how to select records from a table based on the current date.</p>
<div class="p"><pre>Create Table TestDate (
PKCol Int Primary Key,
DecDate Decimal( 9,0 ),
CharDate Char( 8 ) )
Insert Into TestDate Values ( 1, 20010711, '20010711' )</pre>
</div>
<div class="p">Use this SQL statement to compare against the numeric field:<pre>Select *
From TestDate
Where DecDate =
100 * ( 100 * Year( CurDate() ) + Month( CurDate() ) ) +
Day( CurDate() )</pre>
</div>
<div class="p">Using a <tt>Cast</tt> expression, you can convert this 8-digit number to a character value, as in the following example:<pre>Select *
From TestDate
Where CharDate = Cast(
100 * ( 100 * Year( CurDate() ) + Month( CurDate() ) ) +
Day( CurDate() ) As Char( 8 ) )</pre>
</div>
<p>Use care when converting a Month() or Day() return value to a character with <tt>Cast</tt>. If you do not explicitly handle values less than 10, there might be spaces instead of zeros in the result.</p>
</div>
</body>
</html>