Stata
Products Purchase Support Company
Search
   >> Home >> Resources & support >> FAQs >> Current date and time

How can I put the current date and time in my log files?

Title   Current date and time
Author Jeremy B. Wernow, StataCorp
David Kantor, Johns Hopkins University
Date June 2000; updated February 2003

You can put the current date and time into your log files by displaying the global macros where these values are stored.

For example,

 . display "$S_DATE"
 14 Feb 2003

 . display "$S_TIME"
 15:53:01

 . display "$S_TIME  $S_DATE"
 15:53:17  14 Feb 2003

The current date and time are also available as part of the c() class, see help creturn.

 . display c(current_date)
 14 Feb 2003

 . display c(current_time)
 15:56:05

 . display "`c(current_time)' `c(current_date)'"
 15:56:32  14 Feb 2003

David Kantor suggests the following ado-file:

 *! version 1.0
 * Datetime procedure.  Just displays the date and time.
 * Good for use in logged sessions.
 * By David Kantor.  9-26-97
 version 7.0
 program define datetime 
 disp "DateTime: $S_DATE $S_TIME"
 end

It is then easy to include datetime in your do-files.

FAQs
What's new?
Statistics
Data management
Graphics
Programming Stata
Mata
Resources
Internet capabilities
Stata for Windows
Stata for Unix
Stata for Macintosh
Technical support
Resources & support
FAQs
Technical support
NetCourses
Short courses
Users Group meetings
Statalist
Links
Software updates
Software archives
Customer service
Manuals & supplements
Stata Journal
STB
Stata News
Stata Automation
Plugins

Site overview
Products
Resources & support
Company
Site index

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