The DATE function
The DATE function converts a character
string to a DATE value. In the following query, the DATE function
converts a character string to a DATE value to allow for comparisons
with DATETIME values. The query retrieves DATETIME values only when call_dtime is
later than the specified DATE.
Figure 1. Query
SELECT customer_num, call_dtime, res_dtime
FROM cust_calls
WHERE call_dtime > DATE ('12/31/97');
Figure 2. Query
result
customer_num call_dtime res_dtime
106 1998-06-12 08:20 1998-06-12 08:25
110 1998-07-07 10:24 1998-07-07 10:30
119 1998-07-01 15:00 1998-07-02 08:21
121 1998-07-10 14:05 1998-07-10 14:06
127 1998-07-31 14:30
The following query converts DATETIME values to DATE format
and displays the values, with labels, only when call_dtime is
greater than or equal to the specified date.
Figure 3. Query
SELECT customer_num,
DATE (call_dtime) called,
DATE (res_dtime) resolved
FROM cust_calls
WHERE call_dtime >= DATE ('1/1/98');
Figure 4. Query result
customer_num called resolved
106 06/12/1998 06/12/1998
110 07/07/1998 07/07/1998
119 07/01/1998 07/02/1998
121 07/10/1998 07/10/1998
127 07/31/1998