Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fixing VFP 7 crash on date entry
Message
From
16/10/2001 18:34:54
 
 
To
16/10/2001 16:39:00
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00569105
Message ID:
00569343
Views:
43
This message has been marked as a message which has helped to the initial question of the thread.
You can set the appropriate SET DATE, but it does not always work, i.e. if the Windows short date is dd-MMM-yy (16-Oct-01) or if you make a custom date with the year in the middle (dd-yyyy-MM). You could handle it in the error handler, and set it if the error occurs, or set it up front as your set up the app environment.

Here is an example that may serve to give you some ideas of how to implement this, which mostly works. I want to emphasize that I don't expect this to be foolproof in the form below.
LOCAL ldDate, lcDate
ldDate = {^2001-12-31}
lcDate = DTOC(ldDate)
DO CASE 
	CASE RIGHT(lcDate,IIF(SET("Century")='ON',4,2)) = ;
		RIGHT(ALLTRIM(STR(YEAR(ldDate))),IIF(SET("Century")='ON',4,2)) ;
			AND LEFT(lcDate,2) = ALLTRIM(STR(MONTH(ldDate)))
		SET DATE MDY
	
	CASE RIGHT(lcDate,IIF(SET("Century")='ON',4,2)) = ;
		RIGHT(ALLTRIM(STR(YEAR(ldDate))),IIF(SET("Century")='ON',4,2)) ;
			AND LEFT(lcDate,2) = ALLTRIM(STR(DAY(ldDate)))
		SET DATE DMY
	
	CASE LEFT(lcDate,IIF(SET("Century")='ON',4,2)) = ;
			RIGHT(ALLTRIM(STR(YEAR(ldDate))),IIF(SET("Century")='ON',4,2)) ;
			AND RIGHT(lcDate,2) = ALLTRIM(STR(DAY(ldDate)))
		SET DATE YMD
		
	OTHERWISE && Not sure what to do, date format is not recognized
ENDCASE 
RETURN 
>1. Convert SET SYSFORMATS settings to SET DATE settings:
>issue a SET SYSFORMATS ON, determine date format, issue according SET DATE command.
>Which is the simplest way to implement this ?
Jim Saunders
Microsoft
This posting is provided “AS IS”, with no warranties, and confers no rights.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform