从getdate()函数转换时出错

时间:2022-06-23 20:20:22

On command line

在命令行上

convert(varchar,getdate(),120) 

gives below error:

给出以下错误:

Unknown argument '04:59:42.xml'

未知参数'04:59:42.xml'

I am saving data to an xml file. when I use below command,proc works perfectly.

我将数据保存到xml文件。当我使用下面的命令时,proc工作得很好。

convert(varchar,getdate(),112)

I need the file to save with time.

我需要随时间保存文件。

1 个解决方案

#1


0  

You are trying to create a file with a colon in the name, which is not allowed. No way to get around that restriction. However, you can replace the colons with other characters when naming the file, e.g.

您正在尝试创建名称中带冒号的文件,这是不允许的。没办法克服这个限制。但是,您可以在命名文件时将冒号替换为其他字符,例如

replace(convert(varchar,getdate(),120),':','')

#1


0  

You are trying to create a file with a colon in the name, which is not allowed. No way to get around that restriction. However, you can replace the colons with other characters when naming the file, e.g.

您正在尝试创建名称中带冒号的文件,这是不允许的。没办法克服这个限制。但是,您可以在命名文件时将冒号替换为其他字符,例如

replace(convert(varchar,getdate(),120),':','')