导出到 XML 时的 MS Access 日期格式

MS Access date format when exporting to XML

我正在尝试从访问权限导出到 xml。我有一个小问题,它以格式 yyyy/mm/dd:T00:00:00 导出日期。

如何导出没有时间的格式?要么 可以像文本一样创建带有复制日期列的新列。

如何自动完成?谢谢

在您的输出查询中,不要按原样使用日期字段,而是使用表达式:

Format([YourDateField], "yyyy\/mm\/dd")

所以在尝试格式化 Access 中的数据之后。我发现这是不可能的,因为仅使用原始数据导出到 xml。

毕竟我使用了这个转换并且效果很好。 您可以在导出的详细设置中使用它。

<xsl:template match="*">
    <xsl:param name="parentElm">
        <xsl:value-of select="name(..)" />
    </xsl:param>
    <xsl:choose>
        <xsl:when test="local-name() = 'DATUM'">
            <xsl:element name="DATUM">
                <xsl:call-template name="FormatDate">
                    <xsl:with-param name="DateTime" select="."/>
                </xsl:call-template>
            </xsl:element>
        </xsl:when>
        <xsl:otherwise>
            <xsl:element name="{local-name()}">
                <xsl:copy-of select="@*" />
                <xsl:apply-templates select="@* | node()" />
            </xsl:element>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="FormatDate">
    <xsl:param name="DateTime" />
    <xsl:variable name="date">
        <xsl:value-of select="substring-before($DateTime,'T')" />
    </xsl:variable>

    <xsl:if test="string-length($date) != 10">
        <xsl:value-of select="$DateTime"/>
    </xsl:if>
    <xsl:if test="string-length($date) = 10">
        <xsl:value-of select="$date"/>
    </xsl:if>
</xsl:template>
</xsl:stylesheet>