独立日的月份和年份从日期批处理文件 [英] separate day month and year from a date batch file

查看:141
本文介绍了独立日的月份和年份从日期批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样做

 回声%日期%

我得到输出

 宠物2013年6月28日

其他日期

  PON  - >星期一
器 - >星期二
斯雷 - > wedneday
CET - >星期四
宠物 - >星期五
抽泣 - >星期六
NED - >星期日

我写了下面的批处理文件,以获得一天月份和时间。但它不工作。请帮助/

  FOR / F令牌= 1-3 delims =。 %% A IN(%样本%)DO(
    SET天= %%一
    SET月= %%乙
    设置年= %%Ç

回声%一天%
回声%,当月%
回声%,比去年%

输出

  28宠物
06
2013

我想要的输出

  28
06
2013


解决方案

使用

 令牌= 2-4delims =。

注意空格前的结束

when i do

echo %date%

i get output as

pet 28.06.2013

other dates

pon -> monday
tor -> tuesday 
sre -> wedneday 
cet -> thursday 
pet -> friday 
sob -> saturday 
ned -> sunday

I wrote following batch file to get the day month and time. but its not working. please help/

FOR /F "tokens=1-3 delims=." %%A IN ("%sample%") DO (
    SET day=%%A
    SET month=%%B
    SET year=%%C
)
echo %day%
echo %month%
echo %year%

output

pet 28
06
2013

I want the output as

28
06
2013

解决方案

Use

"tokens=2-4delims=. "

Note the SPACE before the closing "

这篇关于独立日的月份和年份从日期批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆