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 on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: Fwd: changing the format of the current date


From   "Cohen, Elan" <cohened@upmc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Fwd: changing the format of the current date
Date   Wed, 22 May 2013 18:58:22 +0000

program define displayDate
        local dt = "`c(current_date)'"
        local m = string(month(td("`dt'")), "%02.0f")
        local d = string(day(td("`dt'")), "%02.0f")
        local y = year(td("`dt'"))
        di "`y' `m' `d'"
end
displayDate


HTH,

- Elan


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Melanie Leis
Sent: Wednesday, May 22, 2013 14:44
To: statalist
Subject: st: Fwd: changing the format of the current date

Hello,

Is there a way to change the format of the automated date in c(current_date)?

The automatic format is 22 May 2013

I would like to get something that looks like 2013 05 22

Any suggestions on how to do this would be greatly appreciated,

Thanks!

Melanie
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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