1.

Solve : changing output format of date command?

Answer»

I'm trying to create a simple batch file to FAMILIARIZE myself with USING the date command.

I want to show the date only (without having to input a date separately) then save the output into a text file. Then I want to change the date. Then I want to take whatever is in the text file and pipe it into the date command. Finally, I want to delete the text file. So far I have this:

Code: [Select]@echo off
date /t >> date.txt
date 09-02-2007
type date.txt | date
del date.txt
exit
However, I have this problem... using the date command along with the /t switch, the output format is like this: Mon 09/03/2007. When I want to pipe the contents of the text file into the date command, the format required is like this: 09/03/2007 (no day of the week). Is there a way to take out the day from the output of the date /t command?

Or... does anyone have any other ideas to help me out with this batch file?

Many thanks beforehand!Hey everyone-
I figured it out, in case anyone was curious. I went into the language and regional settings from control panel and edited the date tab after clicking customize.or u can try excel.
putting formula to separate the text and date
example:

=DATEVALUE(TRIM(LEFT(MID(A1, SEARCH("(", A1) + 1, 999), LEN(MID(A1, SEARCH("(", A1) + 1, 999)) - 1))) + TIMEVALUE(TRIM(LEFT(MID(A1, SEARCH("(", A1) + 1, 999), LEN(MID(A1, SEARCH("(", A1) + 1, 999)) - 1)))
Quote from: only_lonely on September 04, 2007, 01:28:16 AM

or u can try excel

Yes, but... this is the "MICROSOFT DOS" section, and anyway what if you don't have MS Office?
The date is also CONTAINED in the %date% environment variable. And you can customize the output by using substring expansion and the echo command.


Discussion

No Comment Found