Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Left join
Message
 
 
To
26/06/2002 06:58:17
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00672381
Message ID:
00672509
Views:
7
Jimmy,

Datetime values are stored with millisecond level precision and we don't have access to the miliseconds, so using datetime in a join is rarely going to succeed. You need a UDF to convert your datetime to a minute precision value.

function MinuteDateTime( ltValue )
return left( ttoc( ltValue, 1 ), 12 )

YOu can seed your curdates cursor
ltend=datetime()
ltstart=ltend- 24 * 60 * 60 && 7200 is only 2 hours earlier
*the seconds are changed to zero.

CREATE CURSOR curDates (cMinute c(12) )
do while ltstart<=ltend
	INSERT INTO curdates (cMinute) VALUES ( MinuteDatetime( ltstart ) )
	ltstart=ltstart+60
enddo
and then join:
SELECT curDates.cMinute, * FROM registrations
  LEFT JOIN curdates 
    ON MinuteDateTime( Registrations.datetime ) = curdates.cMinute ;
  ORDER BY curdates.cMinute 
  into cursor ctest
>I would like to have a cursor as result with for each minute of the day a registration value if there is no registration for that period then I will change to .null. value to 0.
>
>ltend=datetime()
>ltstart=ltend-7200
>*the seconds are changed to zero.
>
>CREATE CURSOR curDates (dDatetime T)
>do while ltstart<=ltend
> INSERT INTO curdates (dDateTime) VALUES (ltstart)
> ltstart=ltstart+60
>enddo
>
>SELECT * FROM registrations right JOIN curdates ON Registrations.datetime=curdates.dDatetime ;
> ORDER BY curdates.dDateTime into cursor ctest
>
>With this SQL-command I don't get a result the value-field is empty for all the dDatetime-records ??
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform