Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: format of S_DATE global


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: format of S_DATE global
Date   Thu, 16 Aug 2012 16:27:58 +0100

$S_DATE is what it is, but you can evaluate it, change the result to a
numeric date, and then format it. At a guess that would be

tempname hh
file open `hh' using "C:\data\time.csv ", write text append
local date : di %tdN/D/CY date("$S_DATE", "DMY")
file write `hh'  "`date', $S_TIME, `pais', `year', `survey' " _n
file close `hh'

There may be a simpler solution.

Nick

On Thu, Aug 16, 2012 at 4:14 PM, Pablo Bonilla
<[email protected]> wrote:

> In the middle of a program I need to save in a csv file the exact date
> and time in which the program was used by somebody in my office.  I
> use the following script in the middle of the program:
>
> tempname hh
> file open `hh' using "C:\data\time.csv ", write text append
> file write `hh'  "$S_DATE, $S_TIME, `pais', `year', `survey' " _n
> file close `hh'
>
> When I open the CSV file in Excel it understands correctly those dates
> which its days are greater than 10 (e.g., 16 Aug 2012, 15 Apr 2012, 23
> Jul 2012) but those which its days are smaller than 10 (e.g., 6 Aug
> 2012, 5 Apr 2012, 3 Jul 2012) Excel cannot read them as dates. I would
> like to know if I kind change the format of the S_DATE global, so it
> will display 08/16/2012 instead of 16 Aug 2012, So Excel can
> understand. Any other suggestion is more than welcome.
>
> Thanks
>
>
> --
> ----
>
> Pablo Bonilla
> *
> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index