⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datefcn.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 07apr2005}{...}
{cmd:help datefcn}
{hline}

{title:Title}

{p2colset 5 38 43 2}{...}
{p2col :{hi:[U] 24.2.2.2 The date() function}}{hline 2} Inputting
dates (translating dates from strings){p_end}


{title:Syntax}

{p 8 17 2}{it:...} {cmd:date(}{it:str_to_translate}{cmd:,}
		{it:pattern_str}{cmd:)} {it:...}

{p 8 17 2}{it:...} {cmd:date(}{it:str_to_translate}{cmd:,}
		{it:pattern_str}{cmd:,} {it:YYYY_value}{cmd:)} {it:...}

{p 8 17 2}{it:...} {cmd:daily(}{it:...}{cmd:)} {it:...} {space 4} (same as
		{cmd:date()})


{title:Remarks}

    Function description:

{p 4 19 2}1st argument:{space 2}string to be translated to date{p_end}
{p 4 19 2}2nd argument:{space 2}permutation of {cmd:m}, {cmd:d}, {cmd:y} that
  specifies the order in which month ({cmd:m}), day ({cmd:d}), and year
  ({cmd:y}) occur in {it:str_to_translate}{p_end}
{p 4 19 2}3rd argument:{space 2}optional; evaluates to numeric; specifies that
  2-digit years in {it:str_to_translate} are to be interpreted as largest year
  that does not exceed {it:YYYY_value}

{p 4 19 2}Returns:{space 7}{cmd:%d} ({cmd:%td}) date (0=01jan1960, etc.) or
  missing value


{p 4 11 2}Note:  In the first syntax, {cmd:y} in the second argument pattern may
be optionally prefixed with two digits to indicate the default century for
two-digit years, e.g., {cmd:"md19y"} or {cmd:"dm20y"};

{p 4 11 2}Note:  {cmd:daily()} is a synonym for {cmd:date()}; use whichever name
appeals.

{pstd}
See {help dates} and {help tdates} for an explanation of dates.
See {help dfmt} and {help tfmt} for an explanation of date and
time-series formats.


{title:Examples}

{p 4 8 2}{cmd:. generate bdate = date(bstr, "mdy")}{p_end}
{p 4 8 2}{cmd:. format bdate %d}

{p 4 8 2}{cmd:. generate hdate = date(bstr, "md19y")}{p_end}
{p 4 8 2}{cmd:. format hdate %d}

{p 4 8 2}{cmd:. generate expdate = date(bstr, "mdy", 2060)}{p_end}
{p 4 8 2}{cmd:. format expdate %d}


{title:Remarks}

{pstd}
Let {it:s} be a string or string expression that you want to convert;
{it:s} might be a string variable.  {it:s} might contain

	"7-11-1948"
	"07/11/1948"
	"July 11, 1948"
	"Jul11 1948"

    or

	"11-7-1948"
	"11/7/1948"
	"11 July 1948"
	"11jul1948"

{pstd}
Assume {it:s} contains a four-digit year; we will deal with two-digit years
shortly.  The above could be converted into date by typing

	{cmd}. gen birth = date(s,"mdy")
	. format birth %d{txt}
    or
	{cmd}. gen birth = date(s,"dmy")
	. format birth %d{txt}


{title:Two-digit years}

{pstd}Assume {it:s} contains two-digit years:

	"7-11-48"
	"7-11-02"
	"07/11/48"
	"07/11/02"
	"July 11, 48"
	"July 11, 02"

    or

	"11-7-48"
	"11-7-02"
	"11/7/48"
	"11/7/02"
	"11 July 48"
	"11 July 02"

{pstd}There are two ways of dealing with two-digit years:

{phang2}1.  Assume each of the 2-digit years are to be prefixed with a
    fixed number.  In the above, we would assume the years are 1948 and 1902.

{phang2}2.  Assume each of the 2-digit years refers to the maximum year
   that does not exceed YYYY.  Rule 1 with prefix 19 could be achieved by this
   rule with YYYY=1999.  Alternatively, were we to specify YYYY=2040, then 48
   would mean 1948 but 02 would mean 2002.  The split point would be years 40
   and 41; 40 would mean 2040 but 41 would mean 1941.

{pstd}
You may specify Rule 1 by specifying the prefix on {cmd:date()}'s 2nd
argument:

	{cmd:. gen birth = date(s,"md19y")}
    or
	{cmd:. gen birth = date(s,"dm19y")}

{pstd}
You may instead specify Rule 3 by specifying YYYY as {cmd:date()}'s 3rd
argument:

	{cmd:. gen birth = date(s,"mdy",2040)}
    or
	{cmd:. gen birth = date(s,"dmy",2040)}


{title:Also see}

{psee}
Manual:  {bf:[D] functions},{break}
{bf:[U] 24 Dealing with dates},{break}
{bf:[U] 24.2.2.2 The date() function}

{psee}
Online:  {help dates},
{help dfcn},
{help dfmt},
{helpb format},
{help functions},
{help mdyfcn},
{help tdates},
{help tfmt}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -