帮忙写个生成生日格式的批处理
发布网友
发布时间:2022-04-20 06:15
我来回答
共4个回答
热心网友
时间:2022-07-13 06:46
function birthday(x,y)
n=datediff("d",x,y)
m=dateadd("d",-n,y)
for i = 0 to n
d=-datediff("d",m,y)+i
birthday=birthday&dateadd("d",d,y)&vbcrlf
next
end function
'----------使用下面的函数----------'
createobject("scripting.filesystemobject").createtextfile("birthday.txt").writeline birthday("1987-1-16","2000-1")
'---------------使用方法-------------'
'birthday(初始日期,最终日期)
'保存为vbs类型文件
'---------------------------------------'
热心网友
时间:2022-07-13 06:47
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Year, Md2, Mon, Days, Day, List
For Year = 1987 To 2000
If Year / 4 = Int(Year / 4) And Not Year / 400 = Int(Year / 400) Then
Md2 = 29
Else
Md2 = 28
End If
For Mon = 1 To 12
If Mon = 1 Or Mon = 3 Or Mon = 5 Or Mon = 7 Or Mon = 8 Or Mon = 10 Or Mon = 12 Then
Days = 31
ElseIf Mon = 2 Then
Days = Md2
Else
Days = 30
End If
For Day = 1 To Days
List = List & Year & "-" & Mon & "-" & Day & vbCrLf
Next
Next
Next
fso.CreateTextFile("D:\a.txt").Write List
'保存为vbs格式的文件,会在D盘里生成一个a.txt
'批处理太难。
热心网友
时间:2022-07-13 06:47
@echo off
setlocal enabledelayedexpansion
TxtPath=d:\bir.txt
set DaysInMonth[1]=31
set DaysInMonth[2]=28
set DaysInMonth[3]=31
set DaysInMonth[4]=30
set DaysInMonth[5]=31
set DaysInMonth[6]=30
set DaysInMonth[7]=31
set DaysInMonth[8]=31
set DaysInMonth[9]=30
set DaysInMonth[10]=31
set DaysInMonth[11]=30
set DaysInMonth[12]=31
for /l %%y in (1984,1,2000) do (
set base=100
for /l %%m in (1,1,12) do (
REM 为了使月份有两位数,下面使之加100
set /a month=base+%%m
set days=!DaysInMonth[%%m]!
REM 判断闰年
if %%m==2 (
set /a temp=%%y%%400
if !temp!==0 (
set /a days=days+1
) else (
set /a temp=%%y%%100
if not !temp!==0 (
set /a temp=%%y%%4
if !temp!==0 set /a days=days+1
)
)
)
for /l %%d in (1,1,!days!) do (
set /a day=base+%%d
echo %%y-!month:~-2!-!day:~-2! >>%TxtPath%
)
)
)
上面保存成bat文件,双击即可。生成:d:\bir.txt
热心网友
时间:2022-07-13 06:48
保存为bat文件运行
@echo off&setlocal enabledelayedexpansion
(for /l %%a in (1987 1 2000) do (
set /a y=%%a,n=0,leap="^!(y%%4)&^!(^!(y%%100))|^!(y%%400)+28"
for %%b in (31 !leap! 31 30 31 30 31 31 30 31 30 31) do (
set /a n+=1
for /l %%c in (1 1 %%b) do echo %%a-!n!-%%c
)))>tem.txt
start "" "tem.txt"