Windows Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsWindows Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 20th, 2012, 12:39 PM
DKY's Avatar
DKY DKY is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2003
Posts: 998 DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 2 h 30 m 50 sec
Reputation Power: 30
DOS-Batch file find date for last weeks Monday

How do I find the date for last weeks Monday in a DOS batch file?
I would like to pull it into the following format 'yyyy-mm-dd' and assign it to a variable to use as part of a file name later on in the program.
Any help on this would be greatly appreciated, thanks in advance!

Reply With Quote
  #2  
Old September 10th, 2012, 03:10 PM
DKY's Avatar
DKY DKY is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2003
Posts: 998 DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 2 h 30 m 50 sec
Reputation Power: 30
Does anyone know DOS well enough to know if this is possible?

Reply With Quote
  #3  
Old December 24th, 2012, 04:24 AM
admiraln admiraln is offline
Still Learning
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Location: Montreal, Canada
Posts: 55 admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 18 h 57 m 51 sec
Reputation Power: 38
Dos batch may not be powerful enough

Check this out to see an elaborate date manipulation system for dos.

https://groups.google.com/forum/m/?hl=en&fromgroups#!msg/alt.msdos.batch.nt/nPqF9_sT6Wc/ZxXoy7SfzuAJ

Given its complexity, It may be time to give up on dos and move to a more powerful scripting language.
http://strawberryperl.com/

I had done that back in the early 90s and switched to perl for all "batch" work. Today Strawberry perl is a version of perl that included lots of windows specific functionality.

The transition is not hard because. At first all you do is run perl to set variables to values you can't do in dos alone. As you get stronger in it you do more because it's less code and easier.

If you are required to work with Microsoft specific product the alternative is PowerShell. Its run on XP and more recent versions of window. It's MS's official replacement for dos batch files.

I am on vacation this week but I have allocated some recreation hacking time into the day so I may be able to put some scripts together.

Last edited by admiraln : December 24th, 2012 at 04:37 AM. Reason: Fix title

Reply With Quote
  #4  
Old December 29th, 2012, 10:42 PM
DKY's Avatar
DKY DKY is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2003
Posts: 998 DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level)DKY User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 2 h 30 m 50 sec
Reputation Power: 30
I've actually been able to do this with some vb script and DOS...
Example I create a "CreateSQL.vbs" file with notepad
Code:
' Wscript.Echo  DateAdd("d",-1,Now)

Dim LMon
LMon = DateAdd("d",(WeekDay(Date())-2)*-1,Date())

dim filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("F:\PathToSQL\CreatePDTable.sql", True)
path = filesys.GetAbsolutePathName("F:\PathToSQL\CreatePDTable.sql")
getname = filesys.GetFileName(path)
filetxt.WriteLine("DROP TABLE IF EXISTS PARTDATA.TBLPD" & Year(LMon) & Right("0" & Month(LMon),2) & Right("0" & Day(LMon),2) & ";")
filetxt.WriteLine("")
filetxt.WriteLine("CREATE TABLE PARTDATA.TBLPD" & Year(LMon) & Right("0" & Month(LMon),2) & Right("0" & Day(LMon),2))

filetxt.Close

and then I call it with a DOS .bat file like
F:\PathToFile\CreateSQL.vbs
and then in the DOS .bat file I call the .sql file that's created like:
C:\xampp\mysql\bin\mysql -u root -password -D databasename < "F:\PathToSQL\CreatePDTable.sql"

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsWindows Help > DOS-Batch file find date for last weeks Monday

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap