Computing.Net > Forums > Programming > date math: the saga continues

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

date math: the saga continues

Reply to Message Icon

Name: Mechanix2Go
Date: July 25, 2008 at 06:10:43 Pacific
OS: W2K SP3
CPU/Ram: ath1000/512
Product: brand x
Comment:

Since 'date math keeps coming up, I'll have a go.

It will be helpful if a few of you using NT/XP/vista run the bat below and post the first few lines. [Sorry, no good for Me/9x/DOS]

::=====================
@echo off > #

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-d') do (
echo %%~TNa
)


=====================================
If at first you don't succeed, you're about average.

M2



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: July 25, 2008 at 09:47:22 Pacific
Reply:

The first two lines of the output:

25/07/2008 17:45 #
25/07/2008 17:44 t

I am using Windows XP and my locale is English, UK.


0

Response Number 2
Name: Mechanix2Go
Date: July 25, 2008 at 09:56:40 Pacific
Reply:

Thanks klint

I figured there would be 4 dig & 2 dig year.

Gotta see how many diff separators & DMD orderings.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: Rudresh
Date: July 25, 2008 at 16:26:17 Pacific
Reply:

My first two lines of the output are

07/26/2008 04:53 #
07/26/2008 04:53 1

I am using Windows XP and my locale is English, US.

Thanks,
Rudresh


0

Response Number 4
Name: ghostdog
Date: July 25, 2008 at 19:10:06 Pacific
Reply:

date math for files like getting the modification date should be done in vbscript (for example) if you want it to be cross platform or to work in different M$ OS versions.


0

Response Number 5
Name: devil_himself
Date: July 25, 2008 at 22:59:53 Pacific
Reply:
0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: July 26, 2008 at 01:38:23 Pacific
Reply:

Thanks, Rudresh

Ghostdog, youre right, of course. Guess I need to learn VBS.

DH, That script look pretty neat; I'll study it.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 7
Name: Mechanix2Go
Date: July 26, 2008 at 02:39:39 Pacific
Reply:

Hi ghostdog,

Dumb question of the day:

Does VBS work in w9x?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 8
Name: devil_himself
Date: July 26, 2008 at 04:21:12 Pacific
Reply:

yes

delete files older than 30 days

Dim fso
Dim oFolder
Dim oFile

Set fso = createobject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder("C:\Temp")
For Each oFile In oFolder.files
If DateDiff("d", oFile.DateCreated,Now) > 30 Then
oFile.Delete True
End If
Next

Set oFolder = Nothing
Set fso = Nothing


0

Response Number 9
Name: ghostdog
Date: July 26, 2008 at 04:45:50 Pacific
Reply:

the version of the WSH engine in windows 98,2000 and millenium is either 1.0 or 2.0. You can download the latest version (think its 5.6) if you want to use vbs in those platforms. Its good to know about vbscript, since its the next best thing to DOS, natively.


0

Response Number 10
Name: Mechanix2Go
Date: July 26, 2008 at 05:17:57 Pacific
Reply:

Thanks gd & DH,

Got a link to 'VBS for dummies'? or similar


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 11
Name: ghostdog
Date: July 26, 2008 at 05:49:39 Pacific

Response Number 12
Name: Razor2.3
Date: July 27, 2008 at 18:03:12 Pacific
Reply:

You also got me and ghostdog here, if you need help.

Also, while learning VB*, I suggest you make your first line read Option Explicit.


0

Response Number 13
Name: maxbre
Date: July 28, 2008 at 23:46:58 Pacific
Reply:

here is a small contribution to the saga of date math

my output

29/07/2008 08.42 #
29/07/2008 08.42 date

WINDOWS XP, IT

curious to see how is ending up...

bye

max


0

Response Number 14
Name: klint
Date: July 29, 2008 at 10:31:30 Pacific
Reply:

Here's another output I've got today:

07/Tue/08/29 18:25 #

What sort of format is that? 07 is the month, 08 is the year, 29 is the day. Completely insane, I agree, but possible nevertheless.

How did I do that? Easily. I just went into Control Panel, Regional Settings, Customize... the date format is completely configurable.

Which proves there is an almost infinite number of possible formats for the date, and it is impossible to do it in batch.


0

Response Number 15
Name: Razor2.3
Date: July 29, 2008 at 18:05:43 Pacific
Reply:

Back when I ran Win98, I had my time set up as

-=:H.m:=-
Why? because that's how it would be displayed on my task bar.

0

Response Number 16
Name: Mechanix2Go
Date: July 30, 2008 at 06:13:45 Pacific
Reply:

The difficult we do right away.

The impossible takes a little longer.


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: date math: the saga continues

Is it just me? www.computing.net/answers/programming/is-it-just-me/17393.html

date math in BAT, the ongoing saga www.computing.net/answers/programming/date-math-in-bat-the-ongoing-saga/13622.html

The FileList control saga continues... www.computing.net/answers/programming/the-filelist-control-saga-continues/506.html