How to get next Saturday's 'Date'?

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions How to get next Saturday's 'Date'?
# 8  
Old 07-29-2010
Quote:
Originally Posted by methyl
Your question is a bit vague. Not clear whether you need to calculate this date or whether you just wish to provide the date as a parameter.

If you need to calculate this future date on a regular basis this is actually quite difficult even when processing the output from "DATE /T" using "Windows Scripting Host" or some other extension to Windows Batch. Try Microsoft Development Network forums.


If the date just comes from visually reading a calendar, can you post the Batch File highlighting where the date is needed and explain how you expect to pass the date to the Windows Batch script - and in what format.
Hi,
Let me clarify

I have a dos batch file which processes a text file and generates a .csv output file. I want to append the next Saturday date to the output file name.
Right now I am able to append the current date by using the below mentioned logic

Code:
set Pdate=%date:~10,4%%date:~4,2%%date:~7,2% {setting current date to variable}
-outputFile %OUTDIR%\AglItemMaster_"%PDATE%".csv

now I want to pass next saturday date in place of current date.
Kindly help.
A quick response will be really helpful.

---------- Post updated at 01:51 AM ---------- Previous update was at 01:46 AM ----------

Hi,
Let me clarify

I have a dos batch file which processes a text file and generates a .csv output file. I want to append the next Saturday date to the output file name.
Right now I am able to append the current date by using the below mentioned logic

set Pdate=%date:~10,4%%date:~4,2%%date:~7,2% {setting current date to variable}
-outputFile %OUTDIR%\AglItemMaster_"%PDATE%".csv

now I want to pass next saturday date in place of current date.
A quick response will be really helpful.
Thanks in advance.

Last edited by radoulov; 07-29-2010 at 03:50 AM.. Reason: Code tags, please!
# 9  
Old 07-30-2010
Sorry, I don't know any quick dodge in Windows to calculate "next Saturday's date". You already have the YYYY, MM, DD values needed to seed the calculation but not today's day of the week.



Quote:
set Pdate=%date:~10,4%%date:~4,2%%date:~7,2%
Btw Your date format in %date% must be quite different from mine.
Mine is in the format "dd/mm/yyyy" (10 characters).
Therefore yyyymmdd=%date:~6,4%%date:~3,2%%date:~0,2%
# 10  
Old 07-30-2010
Issue resolved.

Thanks a lot all for all you support. I got this solution from the internet

Code:
@echo off
>NextSat.vbs echo wscript.echo FormatDateTime(Date + (7 - Weekday(Date)))
For /f "delims=" %%D in ('cscript //nologo NextSat.vbs') do set nextsaturday=%%D
del NextSat.vbs


echo Next Saturday Is %Nextsaturday% :b:

# 11  
Old 08-01-2010
or

Code:
@echo off
>#.vbs echo wsh.echo "Set Nextsaturday="^&dateAdd("d",7-Weekday(Date),date)
for /f "delims=" %%_ in ('cscript /nologo #.vbs') do %%_
del #.vbs

set Nextsaturday

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Schedule the cron job for every 21day on saturday

Please guide me how to schedule the cron job to run on every Saturday at 6am with the interval of 21 days. (2 Replies)
Discussion started by: raghavendrajsv
2 Replies

2. Shell Programming and Scripting

Scheduling on every 2nd Saturday of a Month

Hi ! I need ur help on a UNIX scheduling Concept understanding : If I need to schedule a job (Say ETL Datastage job) through a shell script using the Cron function to make it run on every second saturday of every month, How can I do it ? :confused: (2 Replies)
Discussion started by: Ravichander
2 Replies

3. Shell Programming and Scripting

cron to get executed on 2nd and 4th saturday of every month

Hi , i need to reboot a server during 2nd and 4th saturday every month. i have come up with the below cron 30 17 8-14 * * if ; then /rebootscript; fi # to reboot every second saturday 30 17 22-28 * * if ; then /rebootscript; fi # to reboot every fourth saturday I am wondering why it... (3 Replies)
Discussion started by: chidori
3 Replies

4. Shell Programming and Scripting

Run cron on every second Saturday ??

Hi, Can anyone help in editing CRON (OR) write a script to run another script every second saturday?? I tried to make use of DATE command to find the day but couldnt proceed further. your help is highly appreciated! Thanks, Mahi (11 Replies)
Discussion started by: mahi_mayu069
11 Replies

5. UNIX for Advanced & Expert Users

How to scedule a script to be run on every second saturday in Month?

Hello Friends, In my project I have to schedule a script to be run on every second saturday (once in month). Can you please suggest what entry should I make in cron ? (5 Replies)
Discussion started by: sourabhsharma
5 Replies

6. Shell Programming and Scripting

Searching for a file, with name Last Sunday through Saturday

Hi List, I need write a script that looks for a file with name File_03-09_to_03-15_data.txt (File_LastSunday_to_LastSaturday_data.txt). If this file is not exists i have to look for a pervious weeks file like File_03-02_to_03-08_data.txt. This loop should continue untill it get a file or no file... (0 Replies)
Discussion started by: rejirajraghav
0 Replies

7. Solaris

How to check for Saturday or Sunday

Hi , I have a date parameter passed in YYYYMMDD format , how can I check whether it is Sat or Sun on Solaris box , as we can do the same easily on linux box by using date -d YYYYMMDD '+a' . Any pointres will be really helpful . (5 Replies)
Discussion started by: harpreetanand
5 Replies

8. Shell Programming and Scripting

Check if a day eg: saturday is the Last saturday of the month!

Hi, I need to develop a script to check for the day. If the day is a Saturday then the script should check if the Saturday is the last Saturday of the month so that certain set of instruction can be executed is it is the last Saturday. I do not want to use the crontab as this needs to be part... (9 Replies)
Discussion started by: jobbyjoseph
9 Replies

9. Shell Programming and Scripting

Date - Last Sunday thru Saturday

Hi All, I have to kick off a script on every Monday to get some data from database for last week (Sunday thru Saturday). If its Monday (12/12/2005) Begin date will be Sunday - 12/4/2005 End date will be Saturday - 12/10/2005 The script might not kick off on some Mondays. So my... (2 Replies)
Discussion started by: skymirror
2 Replies
Login or Register to Ask a Question