Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create Date from Character
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00785368
Message ID:
00785373
Views:
13
>I am trying to create a date from a character expression. I tried CTOD but I ralized that the date has no slashes in it. I always end up parsing the expression and then adding in the pieces and slashes. Is there an easier way to do this?

Would this help?
*FUNCTION todate
LPARAMETERS  tcDate, tcFormat
LOCAL lcFormat, ldDate, lcDate
ldDate = Null
lcFormat = UPPER(ALLTRIM(tcFormat))
DO CASE
CASE lcFormat = "YYYYMMDD"
	lcDate = tcDate
	ldDate = EVALUATE("{^" + TRANSFORM(lcDate, "@R 9999/99/99") + "}")				
CASE lcFormat = "YYMMDD"
	lcDate = LEFT( STR( YEAR( DATE()),4),2) + tcDate
	ldDate = EVALUATE("{^" + TRANSFORM(lcDate, "@R 9999/99/99") + "}")				
OTHERWISE
ENDCASE
RETURN ldDate
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform