Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting smalldatetime to vfp date
Message
General information
Forum:
Microsoft SQL Server
Category:
Database management
Miscellaneous
Thread ID:
01032852
Message ID:
01032920
Views:
13
Hi Dmitry

I have solved this problem by using CursorfieldsDateTimeToDate funtion
This function supports long field names and read only cursor type. In addition excecution time is very short

Ali Altun
CursorFieldsDateTimeToDate(cCursor)

*************


FUNCTION CursorFieldsDateTimeToDate(cCursor)

local ii, nElement, cField

cFieldStr = CURSORFIELDSTR(cCursor)
nElement = alines(aFieldStr, strtran(cFieldStr, ',', chr(10)))

for ii = 1 to nElement
	cField = alltrim(aFieldStr(ii))
	
	if type("&cCursor..&cField")="T"
		if ii = 1
			cFieldStr = strtran(cFieldStr, cField, "cast("+cField+" as date) "+cField)
		else
			cFieldStr = strtran(cFieldStr, ", "+cField, ", cast("+cField+" as date) "+cField)
		endif
	endif
endfor

select &cFieldStr from &cCursor into cursor &cCursor readwrite

return 


************

FUNCTION CURSORFIELDSTR(cCursor)

local cFieldStr 

if !used(cCursor) and substr(cCursor,1,3)<>"cur"
	use &cCursor In 0 Alias &cCursor
endif


cFieldStr  = ""
nFieldAdet = AFIELDS(arrFields, cCursor)



for ii = 1 TO nFieldAdet
	cFieldStr = cFieldStr+iif(ii=1, '', ' , ')+alltrim(lower(arrFields(ii, 1)))
endfor

return cFieldStr 

ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform