Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function to convert date to words
Message
From
27/03/2003 16:22:53
Peter Easson
Catalina Trading
Sydney, Australia
 
 
To
27/03/2003 12:15:53
Stephen Hunt
Admit Computer Services Inc.
Farmingdale, New York, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00770814
Message ID:
00770993
Views:
14
? LongDate("01/01/2003")
? LongDate(Datetime())
? LongDate(Date())

FUNCTION LongDate(xDate)
	IF VARTYPE(xDate) = "C"
		IF LEN(xDate) = 10 AND ! EMPTY(CTOD(xDate))
			xDate = CTOD(xDate)
		ELSE 
			RETURN 0
		ENDIF 
	ENDIF 		
	IF VARTYPE(xDate) = "T"
	    RETURN ;
		CDOW(xDate) + ", " + CMONTH(xDate) + " " + ALLTRIM(STR(DAY(xDate))) + ", " +;
				ALLTRIM(STR(YEAR(xDate))) + " at " + TTOC(xDate,2)
	ELSE 
		IF VARTYPE(xDate) = "D"		
			RETURN ;
				CDOW(xDate) + ", " + CMONTH(xDate) + " " + ALLTRIM(STR(DAY(xDate))) + ", " +;
					ALLTRIM(STR(YEAR(xDate)))
		ENDIF 
	ENDIF 	
ENDFUNC 
FUNCTION ShortDate(cLongDate as String,lAsDate as Boolean) && eg Sunday, March 30, 2003 			
	LOCAL mMonth as String,mDay as String, mYear as String,mDate as String, mPos AS Integer  
	cLongDate = SUBSTR(cLongDate,AT(",",cLongDate,1) + 2) && Strip off the day
	mMonth = SUBSTR(cLongDate,1,AT(" ",cLongDate,1))
	cLongDate = SUBSTR(cLongDate,AT(" ",cLongDate,1) + 1) && Strip off the Month
	mDay = SUBSTR(cLongDate,1,AT(" ",cLongDate,1) - 2)
	cLongDate = SUBSTR(cLongDate,AT(" ",cLongDate,1) + 1) && Strip off the Day
	mYear = cLongDate
	mPos = ASCAN(oP.Arrays.Month.aArray,mMonth)
	IF mPos > 0
		mPos = INT(mPos/4) + 1
		mMonth = ALLTRIM(STR(oP.Arrays.Month.aArray[mPos,4]))
	ELSE 
		RETURN CTOD("")
	ENDIF 		
	mDate = SET("Date")
	SET DATE DMY
	cLongDate = mDay +"/" + mMonth + "/" + mYear && reuse the variable
	IF lAsDate
		cLongDate = CTOD(cLongDate)
	ENDIF 
	SET DATE &mDate
	RETURN cLongDate
ENDFUNC
Previous
Reply
Map
View

Click here to load this message in the networking platform