142 lines
8.3 KiB
XML
142 lines
8.3 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<helpdocument version="1.0">
|
|
<!--
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
-->
|
|
|
|
<meta>
|
|
<topic id="textsbasicshared03150000xml" indexer="include" status="PUBLISH">
|
|
<title id="tit" xml-lang="en-US">FormatDateTime Function [VBA]</title>
|
|
<filename>/text/sbasic/shared/03150000.xhp</filename>
|
|
</topic>
|
|
</meta>
|
|
|
|
<body>
|
|
|
|
<section id="FormatDateTime">
|
|
<bookmark xml-lang="en-US" branch="index" id="bm_id3150499">
|
|
<bookmark_value>FormatDateTime function</bookmark_value>
|
|
</bookmark>
|
|
|
|
<h1 id="hd_id3150499" xml-lang="en-US"><link href="text/sbasic/shared/03150000.xhp">FormatDateTime Function [VBA]</link></h1>
|
|
<paragraph id="par_id3151384" role="paragraph" xml-lang="en-US">Applies a date and/or time format to a date expression and returns the result as a string.</paragraph>
|
|
</section>
|
|
<embed href="text/sbasic/shared/00000003.xhp#vbasupport"/>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
|
|
<bascode>
|
|
<paragraph id="par_id3143267" role="bascode" localize="false" xml-lang="en-US">FormatDateTime (Date As Date [, NamedFormat As Integer])</paragraph>
|
|
</bascode>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functvalue"/>
|
|
<paragraph id="par_id3150669" role="paragraph" localize="false" xml-lang="en-US">String</paragraph>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
|
|
<paragraph id="par_id240720170117391741" role="paragraph" xml-lang="en-US"><emph>Date</emph>: The date expression to be formatted.</paragraph>
|
|
<paragraph id="par_id24072017011739895" role="paragraph" xml-lang="en-US"><emph>NamedFormat</emph>: An optional <emph>vbDateTimeFormat</emph> enumeration specifying the format that is to be applied to the date and time expression. If omitted, the value <emph>vbGeneralDate</emph> is used.</paragraph>
|
|
<h3 id="hd_id811512136434300">Date and Time formats (vbDateTimeFormat enumeration)</h3>
|
|
<section id="FormatDateTime_constants">
|
|
<table id="tab_0001">
|
|
<tablerow>
|
|
<tablecell>
|
|
<paragraph role="tablehead" id="par_id201512137337536" xml-lang="en-US">Named Constant</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph role="tablehead" id="par_id481512137342798" xml-lang="en-US">Value</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph role="tablehead" id="par_id781512137345583" xml-lang="en-US">Description</paragraph>
|
|
</tablecell>
|
|
</tablerow>
|
|
<tablerow>
|
|
<tablecell>
|
|
<paragraph role="tablecontents" id="par_id121512137348477" xml-lang="en-US" localize="false">vbGeneralDate</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph role="tablecontents" id="par_id511512137351182" xml-lang="en-US" localize="false">0</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph role="tablecontents" id="par_id991512137353869" xml-lang="en-US">Displays a date and/or time as defined in your system's General Date setting. If a date only, no time is displayed; If a time only, no date is displayed.</paragraph>
|
|
</tablecell>
|
|
</tablerow>
|
|
<tablerow>
|
|
<tablecell>
|
|
<paragraph id="par_id181512137579110" role="tablecontents" xml-lang="en-US" localize="false">vbLongDate</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id651512137595327" role="tablecontents" xml-lang="en-US" localize="false">1</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id841512137597989" role="tablecontents" xml-lang="en-US" >Display a date using the long date format specified in your computer's regional settings.</paragraph>
|
|
</tablecell>
|
|
</tablerow>
|
|
<tablerow>
|
|
<tablecell>
|
|
<paragraph role="tablecontents" id="par_id391512138077008" xml-lang="en-US" localize="false">vbShortDate</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id651512137594327" role="tablecontents" xml-lang="en-US" localize="false">2</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id841512137397989" role="tablecontents" xml-lang="en-US" >Display a date using the short date format specified in your computer's regional settings.</paragraph>
|
|
</tablecell>
|
|
</tablerow>
|
|
<tablerow>
|
|
<tablecell>
|
|
<paragraph id="par_id181512137679110" role="tablecontents" xml-lang="en-US" localize="false">vbLongTime</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id651512137595227" role="tablecontents" xml-lang="en-US" localize="false">3</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id841512147597989" role="tablecontents" xml-lang="en-US" >Displays a time as defined in your system's Long Time settings.</paragraph>
|
|
</tablecell>
|
|
</tablerow>
|
|
<tablerow>
|
|
<tablecell>
|
|
<paragraph id="par_id183512137579110" role="tablecontents" xml-lang="en-US" localize="false">vbShortTime</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id651512937595327" role="tablecontents" xml-lang="en-US" localize="false">4</paragraph>
|
|
</tablecell>
|
|
<tablecell>
|
|
<paragraph id="par_id841517137597989" role="tablecontents" xml-lang="en-US" >Display a time using the 24-hour format (hh:mm).</paragraph>
|
|
</tablecell>
|
|
</tablerow>
|
|
</table>
|
|
</section>
|
|
|
|
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
|
|
<embed href="text/sbasic/shared/00000003.xhp#err13"/>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
|
|
<bascode>
|
|
<paragraph role="bascode" id="par_id851512148348809" xml-lang="en-US" localize="false">REM ***** BASIC *****</paragraph>
|
|
<paragraph role="bascode" id="par_id981512148374491" xml-lang="en-US" localize="false">Option VBASupport 1</paragraph>
|
|
<paragraph role="bascode" id="par_id541512148389055" xml-lang="en-US" localize="false">Sub DateFormat</paragraph>
|
|
<paragraph role="bascode" id="par_id91512148403780" xml-lang="en-US" localize="false"> Dim d as Date</paragraph>
|
|
<paragraph role="bascode" id="par_id551512148424467" xml-lang="en-US" localize="false"> d = ("1958-01-29 00:25")</paragraph>
|
|
<paragraph role="bascode" id="par_id541512148446032" xml-lang="en-US"> msgbox("General date format : " & FormatDateTime(d))</paragraph>
|
|
<paragraph role="bascode" id="par_id71512148472413" xml-lang="en-US" > msgbox("Long date format : " & FormatDateTime(d,vbLongDate))</paragraph>
|
|
<paragraph role="bascode" id="par_id561512148491949" xml-lang="en-US" > msgbox("Short date format : " & FormatDateTime(d,vbShortDate))</paragraph>
|
|
<paragraph role="bascode" id="par_id521512148501199" xml-lang="en-US" > msgbox("Long time format : " & FormatDateTime(d,3))</paragraph>
|
|
<paragraph role="bascode" id="par_id521512148513930" xml-lang="en-US" > msgbox("Short time format : " & FormatDateTime(d,vbShortTime))</paragraph>
|
|
<paragraph role="bascode" id="par_id211512148529064" xml-lang="en-US" localize="false">End Sub</paragraph>
|
|
</bascode>
|
|
|
|
<section id="relatedtopics">
|
|
<embed href="text/sbasic/shared/00000003.xhp#VBATimeAndDate"/>
|
|
</section>
|
|
</body>
|
|
|
|
</helpdocument>
|