John-Paul Ferguson wrote (excerpted):
My question therefore is this: how can I retrieve the current date or time
and hold it as a genuine string, such that I can manipulate it?
----------------------------------------------------------------------------
Something like the following should work.
Joseph Coveney
program autolog
local now = subinstr("`c(current_time)'", ":", "", .)
local today = string(date("`c(current_date)'", "dmy"), "%dCYND")
local timestamp `today'T`now'
// capture log close
log using `timestamp'.log, replace
end
. autolog
(note: file A:\20050325T143342.log not found)
----------------------------------------------------------------------------
----------------------
log: A:\20050325T143342.log
log type: text
opened on: 25 Mar 2005, 14:33:43
. log close
log: A:\20050325T143342.log
log type: text
closed on: 25 Mar 2005, 14:33:46
----------------------------------------------------------------------------
----------------------
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/