In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to calculate the number of days of batch processing, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Code 1.
:: DateDel2.bat-deletes files previously modified by the specified number of days under the specified path
Note: variable tian is the specified number of days, 1 yesterday, 2 the day before yesterday, and so on
:: core algorithm: Ritchie Lawrence, updated 2002-08-13. Version 1.1
::
@ echo off & setlocal ENABLEEXTENSIONS
Call: Date2Day% date:~0,10% sdays
% tian% of the rem downstream represents the number of days.
Set / p tian= Please specify the number of days to retrace:
Set / a sdays-=tian
Call: Day2Date% sdays% difdate
Echo.&echo.
The date specified by echo is:% date:~0,10%
Echo.
Echo% tian% days ago the date is:% difdate%
Echo.&pause
Exit
: Date2Day
Setlocal ENABLEEXTENSIONS
For / f "tokens=1-3 delims=/-," an in ('echo/%1') do (
Set yy=%%a & set mm=%%b & set dd=%%c
)
Set / a dd=100%dd%%0,mm=100%mm%%0
Set / a zaqiang 14qmm penny pencils 12department yay yyies 4800liz repertoire mlbs 12m squares 3jacks 153mm penny 2
Set / a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
Endlocal&set% 2=%j%&goto: EOF
: Day2Date
Setlocal ENABLEEXTENSIONS
Set / axioms% 1 Personality 2472632, reparations bimonthly, 4memaurs, 3reparations, baccades, 146097, 146097, racquets, 146097, 146097, 146097, 146097, flashes.
Set / a dancers 4mlbs 3 minutes dpact 1461 gimmick 1461 fuzz 1461 squares dwelling e-makings 4 legends e-mails c memorials 5 praises 2 grinds 2 mores, 153 dads, 153 packs, 2 pads, 5
Set / a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if% mm% LSS 10 set mm=0%mm%) & (if% dd% LSS 10 set dd=0%dd%)
Endlocal&set% 2=%yy%-%mm%-%dd%&goto: EOF
Code 2.
@ echo off
: ask for the date of N days ago
:: train of thought
:: simulate manual operation, subtract the number of days with the number of days, and borrow 1 from the high position when the difference is negative.
Features:
The code is concise and easy to understand, and the speed depends on the number of days specified
Dates can be marked with weeks, but they must be arranged in the order of years, months and days
:: the year must be four digits, otherwise there will be an error
@ echo off
: Main
Cls
Set day=%date%
Set days=0
Echo.&echo.
The date specified by echo is:% day%
Echo.
Set / p input= Please specify the number of days to retrace:
Setlocal enabledelayedexpansion
:: extraction date
For / f "tokens=1-3 delims=-/." I in ("% day%") do (
Set / a sy=%%i, sm=100%%j 100, sd=100%%k 100
)
Set / a sd-=input
If% sd% leq 0 call: count
Cls
Echo.&echo.
The date specified by echo is:% day%
Echo.
Set sm=0%sm%
Set sd=0%sd%
Echo% input% days ago the date is:% sy%-%sm:~-2%-%sd:~-2%
Pause > nul
Goto Main
: count
Set / a sm-=1
If! sm! Equ 0 set / a sm=12, sy-=1
Call: days
Set / a sd+=days
If sd% leq 0 goto count
Goto: eof
: days
:: gets the total number of days in a specified month
Set / a leap= "^! (sy% 4) & ^! (^! (sy% 100)) | ^! (sy% 400)"
Set / a max=28+leap
Set num=0
Set str=31% max% 31 30 31 30 31 31 30 31 30 31
For I in (str%) do (
Set / a num+=1
If sm% equ! num! Set days=%%i&goto: eof
)
Goto: eof
The above is all the contents of the article "how to calculate days in batch processing". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.