Dear All,

I have a string date-second variable from which I need to extract year, quarter, month, week, day etc.

Here is the description:

storage display value
variable name type format label variable label
-----------------------------------------------------------------------------------------
datescriptwri~n str19 %19s date of writing of script
And it is listed as:

Code:
. list datescriptwritten

          +---------------------+
          |   datescriptwritten |
          |---------------------|
       1. | 2011-01-03 00:00:00 |
       2. | 2011-01-02 00:00:00 |
       3. | 2011-01-04 00:00:00 |
       4. | 2011-01-04 00:00:00 |
       5. | 2011-01-04 00:00:00 |
          |---------------------|
How may I extract year, quarter etc. from this format? I tried the following:

Code:
. gen yeardisp=year(datescriptwritten)
type mismatch
r(109);
Thank you for your help.
Sincerely,
Sumedha.