📄 dexfcns.hlp
字号:
{smcl}
{* 07apr2005}{...}
{cmd:help dexfcns}
{hline}
{title:Title}
{p2colset 5 37 42 2}{...}
{p2col :{hi:[U] 24.2.4 Other date functions}}{hline 2} Component
extraction functions for dates{p_end}
{title:Syntax}
{p 8 40 2}{it:...} {cmd:year(}{it:date_exp}{cmd:)} {it:...} {space 6} returns four-digit year; e.g., 1980, 2002{p_end}
{p 8 40 2}{it:...} {cmd:month(}{it:date_exp}{cmd:)} {it:...} {space 5} returns month; 1 - 12{p_end}
{p 8 40 2}{it:...} {cmd:day(}{it:date_exp}{cmd:)} {it:...} {space 7} returns day within month; 1 - 31{p_end}
{p 8 40 2}{it:...} {cmd:halfyear(}{it:date_exp}{cmd:)} {it:...} {space 2} returns the half of the year; 1 or 2{p_end}
{p 8 40 2}{it:...} {cmd:quarter(}{it:date_exp}{cmd:)} {it:...} {space 3} returns quarter; 1, 2, 3, or 4{p_end}
{p 8 40 2}{it:...} {cmd:week(}{it:date_exp}{cmd:)} {it:...} {space 6} returns week; 1, 2, ..., 52{p_end}
{p 8 40 2}{it:...} {cmd:dow(}{it:date_exp}{cmd:)} {it:...} {space 7} returns day of week; 0, 1, ..., 6; 0=Sunday{p_end}
{p 8 40 2}{it:...} {cmd:doy(}{it:date_exp}{cmd:)} {it:...} {space 7} returns day of year; 1, 2, ..., 366{p_end}
{title:Remarks}
{pstd}
Function description:
{p 4 19 2}Argument:{space 2}{cmd:%d} ({cmd:%td}) date (see remarks below){p_end}
{p 4 19 2}Returns:{space 3}as given above{p_end}
{p 4 4 2}
See help {help dates} and help {help tdates} for an explanation of dates.
See help {help dfmt} and help {help tfmt} for an explanation of date and
time-series formats. See help {help functions} for other functions.
{title:Examples}
{p 4 8 2}{cmd:. gen birthyr = year(bdate)}
{p 4 8 2}{cmd:. gen qtr = quarter(dofq(time))}
{p 4 8 2}{cmd:. gen problem = (dow(hiredate)==6 | dow(hiredate)==0)}
{title:Remarks}
{p 4 4 2}
Note that all extraction functions require a {cmd:%d} ({cmd:%td}) date as
an argument. If your variable is recorded in weeks, months, quarters, half
years, or years, use the date-conversion functions; see help {help dcfcns}.
For instance, in the second example above, we coded
{p 8 12 2}{cmd:. gen qtr = quarter(dofq(time))}
{p 4 4 2}
In this example, variable time is a {cmd:%tq}-format date; see help
{help tfmt}. {cmd:dofq()} converted time to a {cmd:%d} (or {cmd:%td} or
daily, as you prefer) date suitable for use by {cmd:quarter()}.
{title:Also see}
{psee}
Manual: {bf:[D] functions},{break}
{bf:[U] 24 Dealing with dates},{break}
{bf:[U] 24.2.4 Other date functions}
{psee}
Online: {help dates},
{help dcfcns},
{help dfmt},
{help dlyfcns},
{helpb format},
{help functions},
{help tdates},
{help tfmt}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -