[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Issue with date function

From   "Nick Cox" <>
To   <>
Subject   RE: st: Issue with date function
Date   Mon, 7 Apr 2008 18:00:33 +0100

Liz's advice applies to Stata 9 (and back some). It does not apply to
Stata 10
(unless under version control): 

. di date("31/12/94", "dm19y")

. version 9 : di date("31/12/94", "dm19y")


Elizabeth Allred

gen datef = date(datestr, "dm19y")

Note d m and y are lower case. Upper case does NOT work.


> I'm haing a problem with the date function when trying to convert a
> variable into a date variables. My string variable is datestr and
> dates in the following format "31/12/94", ie, DMY. I've tried to use
> date function using the following syntax:
> gen datef = date(datestr, "DMY")
> I've already used this deffinition and it worked well, but the date
had the
> format "31/12/1994". Is there a way of using the date function with
> format I'm currently using, ie, with the last two digits in year?

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index