PC Review


Reply
Thread Tools Rate Thread

Date & Time Format

 
 
Daniel
Guest
Posts: n/a
 
      9th May 2006
Hello Everyone,

I have a small problem. I have a batch that has the following:
-------Start---------

set zdate=%date:~4%
set zdate=%zdate:/=%
set ztime=%time::=%
set ztime=%ztime:~0,6%

copy c:\TestText.txt C:\%zdate%%ztime%.txt

-----------End-----------

The batch runs great except if it is ran before 10:00 and the time has a
single digit hour then it puts a SPACE between the date and time in the text
name. This causes problems and I need to find a way to either not have the
space or put a zero before the hour.

Any help is greatly appreciated.

Thanks,

Daniel


 
Reply With Quote
 
 
 
 
foxidrive
Guest
Posts: n/a
 
      9th May 2006
On Tue, 9 May 2006 11:52:20 -0500, Daniel wrote:

> Hello Everyone,
>
> I have a small problem. I have a batch that has the following:
> -------Start---------
>
> set zdate=%date:~4%
> set zdate=%zdate:/=%
> set ztime=%time::=%


Add this:

set ztime=%time :0=%

> set ztime=%ztime:~0,6%
>
> copy c:\TestText.txt C:\%zdate%%ztime%.txt
>
> -----------End-----------
>
> The batch runs great except if it is ran before 10:00 and the time has a
> single digit hour then it puts a SPACE between the date and time in the text
> name. This causes problems and I need to find a way to either not have the
> space or put a zero before the hour.


It'll do the latter.
 
Reply With Quote
 
Timo Salmi
Guest
Posts: n/a
 
      9th May 2006
Daniel wrote:
> The batch runs great except if it is ran before 10:00 and the time
> has a single digit hour then it puts a SPACE between the date and
> time in the text name. This causes problems and I need to find a
> way to either not have the space or put a zero before the hour.


:: See to it that days 1-9 will always have a leading zero
set dd_=0%dd_%
set dd_=%dd_:~-2%

More fully in
163586 May 1 2006 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
private.php?do=newpm&u= <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting text format of time/date into Excel time/date for subtr YY san. Microsoft Excel Worksheet Functions 5 25th Feb 2010 07:13 AM
Convert date + time text format to date format =?Utf-8?B?UGF1bCBIbw==?= Microsoft Excel Worksheet Functions 2 22nd May 2007 05:47 PM
Convert a latebinded DataTable column's format from DateTime to string (or format the date time value) RSH Microsoft VB .NET 0 6th Dec 2006 03:49 PM
Export Outlook date field as date/time format to Access database =?Utf-8?B?QmVja3k=?= Microsoft Outlook Discussion 0 2nd Dec 2004 02:49 PM
Converting Date Time format to Month YEar format Prashant Sisodia Microsoft Excel Worksheet Functions 1 11th Jun 2004 03:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:09 AM.