如何根据系统日期将输出文本文件命名为 YYYYMMDD? [英] How do I name the output textfile to YYYYMMDD based on the system date?
本文介绍了如何根据系统日期将输出文本文件命名为 YYYYMMDD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何根据系统日期将输出文本文件命名为 YYYYMMDD?
How do I name the output textfile to YYYYMMDD based on the system date?
sqlcmd -S DataBBB -i c:\scripts\followup.sql
-o %DATE:~4,2%_%DATE:~7,2%_%DATE:~-4%.txt -s ; -W -u
现在输出的文本文件是01_31_2012.txt
.如何将其更改为 2012_01_31.txt
?
Now the output text file is 01_31_2012.txt
.
How can I change it to 2012_01_31.txt
?
推荐答案
在 Windows 7 Premium(德语)下尝试过,可能取决于操作系统和本地时间格式.
Tried it under Windows 7 Premium (German), may be dependent upon OS and Local Time Format.
sqlcmd -S DataBBB -i c:\scripts\followup.sql
-o %date:~-4%_%date:~3,2%_%date:~0,2%.txt -s;
您必须为您的系统编辑此部分
You have to edit this part for your system
%date:~-4%_%date:~3,2%_%date:~0,2%.txt
该语句使用命令行内部 %date%
- 带有扩展名 :~start,length
的变量.因此,您可以使用 date
- 变量中的不同部分创建文件名.
The statement used the command line internal %date%
- variable with the extension :~start,length
. So you can create the filename with different parts from the date
- variable.
这篇关于如何根据系统日期将输出文本文件命名为 YYYYMMDD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文