longtom 发表于 2014-3-14 08:52 
2012是什么意思?
Working with two-digit years
Consider translating the string 01-12-06 14:22, which is to be interpreted as 01dec2006 14:22:00. The translation functions provide two
ways of doing this.
The first is to specify the assumed prefix in the mask. The string 01-12-06 14:22 can be read by specifying the mask "DM20Yhm". If we
instead wanted to interpret the year as 1906, we would specify the mask "DM19Yhm". We could even interpret the year as 1806 by specifying
"DM18Yhm".
What if our data include 01-12-06 14:22 and include 15-06-98 11:01? We want to interpret the first year as being in 2006 and the second
year as being in 1998. That is the purpose of the optional argument topyear:
clock(string, mask [, topyear])
When you specify topyear, you are stating that when years in string are two digits, the full year is to be obtained by finding the largest
year that does not exceed topyear. Thus you could code
. generate double timestamp = clock(timestr, "DMYhm", 2020)
The two-digit year 06 would be interpreted as 2006 because 2006 does not exceed 2020. The two-digit year 98 would be interpreted as 1998
because 2098 does exceed 2020.