Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DTOS
Message
From
11/07/2001 10:14:58
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: DTOS
Miscellaneous
Thread ID:
00528987
Message ID:
00529121
Views:
26
>That's similar to what I was using, I was just curious if there was an internal VFP function that did it for you, one that I missed. Thanks though.

There is no such internal function.

My own version of the function (it is convenient to declare a function, so you can call it as one):
FUNCTION STOD(tcDateString)
	* Converse of dtos. I use this to embed a date in a string of parameters, and extract it again.
	* The date string, of course, must conform to the standard imposed by the dtos() function:
	* yyyymmdd (8 digits, with no separators).
	if empty(tcDateString)
		return {}
	endif
	return date(;
		val(substr(tcDateString,1,4)),;
		val(substr(tcDateString,5,2)),;
		val(substr(tcDateString,7,2)))
ENDFUNC && STOD
I didn't add error-checking yet; I am just realizing that date() will probably fail for Feb. 30, etc. In this case, you should return an empty string, or a null value (of date type).

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform