<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - CDate
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="cbyte+en">Previous</a>&nbsp;
<a href="cfloat+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
CDate
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Date</u> <b>= CDate (</b> <u>Expression</u> AS Variant <b>)</b> AS Date</pre><p>

Converts an expression (numerical <a href="type/float+en">Float</a> or <a href="../comp/gb/string+en">String</a>) into a <a href="type/date+en">Date</a> / <a href="time+en">Time</a> <a href="../comp/gb/string+en">String</a>.
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
Be careful! The current localization is <b>not</b> used by this function.
</td></tr></table></div>
<p>

<div class="gray"><font size="-2"><b>Errors</b></font></div>
<table class="table" border="0" bordercolor="#000000" cellpadding="6" cellspacing="0" width="100%">
<tr><th>Message</th><th>Description</th></tr><tr class="dark"><td valign="top">
<a href="../error/type+en">Type mismatch (#6)</a>
</td><td valign="top">
<u>Expression</u> cannot be converted.
</td></tr>
</table>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT CDate(&quot;09/06/1972 01:45:12&quot;)
<hr>09/06/1972 01:45:12</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT CDate(2484515)
<hr>05/16/2002</pre>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;<ul>
<li>If the expression is numeric, and is below 1.0000 then only a time is returned in the format &quot;hh:mm:ss&quot;.
&nbsp;&nbsp;&nbsp;&nbsp;<li>If the expression is numeric, and is greater than 1.0000 and its fraction is 0.00 then only the <a href="date+en">Date</a> is returned in a european short format. &quot;dd.mm.yy&quot;
&nbsp;&nbsp;&nbsp;&nbsp;<li>If the expression is numeric, and is greater than 1.0000 and its fraction is not 0.00 then the <a href="date+en">Date</a> and the time is returned in a european short format. &quot;dd.mm.yyyy hh:mm:ss&quot;.
<p>
</ul>

<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">CDate(86398/86400)          23:59:58
CDate(1.2)                  01.01.-4801 04:48:00
CDate(-0.25)                18:00:00
CDate(-1.25)                18:00:00
CDate(-500 + 3 / 86400)     00:00:03
CDate(2472692)              01.01.70
CDate(2472693)              02.01.70
CDate(2472693 + 1 / 86400)  02.01.1970 00:00:01
CDate(2472693 + 1 / 1440)   02.01.1970 00:01:00
CDate(2472693.25)           02.01.1970 06:00:00</pre>
<p>
<hr><b>See also</b><br>
<a href="../cat/conv+en">Conversion Functions</a>&nbsp;

</div>
</body>
</html>

