Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: AW: Question on using formatted dates in a filename (or getting it into a local)


From   Nick Winter <nwinter@virginia.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: Question on using formatted dates in a filename (or getting it into a local)
Date   Tue, 30 Mar 2010 11:44:18 -0400

If this works

di %tdCCYY.NN.DD date(c(current_date),"DMY")

then you can put it in a local like this:

local date : di %tdCCYY.NN.DD date(c(current_date),"DMY")


On 3/30/2010 11:02 AM, Martin Weiss wrote:
<>
Michael`s Stata Tidbit http://www.michaelnormanmitchell.com/stow/always-starting-a-log.html of a couple of weeks ago also contains useful advice in the area you are concerned with.



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Eduard Grebe
Gesendet: Dienstag, 30. März 2010 16:45
An: statalist@hsphsun2.harvard.edu
Betreff: st: Question on using formatted dates in a filename (or getting it into a local)

Dear All

I would like to save my logs in a way that sorts them chronologically in
the filesystem. For this they have to have dates formatted as follows:
2010.03.30-logfilename.log

However, I am struggling to create a local containing the current date
in that format. I am managing to display the current date that way, but
not putting it in a local.

This:
        di %tdCCYY.NN.DD date(c(current_date),"DMY")
Gives this output:
        2010.03.30
But, this
        local date = string(date(c(current_date), "dmy"), "%
        tdCCYY.NN.DD")
        di `date'
Gives an empty output.

Can anyone point me in the right direction?

Thanks!
Eduard


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  nwinter@virginia.edu e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, S385 Gibson Hall
Charlottesville, VA 22904

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index