[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
John-Paul Ferguson <jpferg@mit.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Extracting a string from c(current_time) |

Date |
Fri, 25 Mar 2005 09:12:44 -0500 |

That answered my question. Thanks to Joseph for a more compact way of doing it, and to Ichiro for an explanation of where I was going wrong. --John-Paul Ferguson Quoting Ichiro Fujikake <fujikake@cc.miyazaki-u.ac.jp>: > Hi > > Another way is to use > local time =c(current_time) > or > local time `c(current_time)' > in place of > local time c(current_time) > > I might be incorrect, but my guess here is that when macro time is called at > subinstr, it is treated as string, so that c() isn't evaluated. It should > have evaluated before it was placed in macro time, and that's = or `' does. > Joseph Conveney's solution also uses `c()' for the same reason. > > Ichiro > > > On 05.3.25 14:38, "Joseph Coveney" <jcoveney@bigplanet.com> wrote: > > > 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/ > > > > > * > * 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/ > * * 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/

**References**:**Re: st: Extracting a string from c(current_time)***From:*Ichiro Fujikake <fujikake@cc.miyazaki-u.ac.jp>

- Prev by Date:
**st: adding text to "by graphs"** - Next by Date:
**st: RE: adding text to "by graphs"** - Previous by thread:
**Re: st: Extracting a string from c(current_time)** - Next by thread:
**st: adding text to "by graphs"** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |