Tengo un Fichero access, y necesito ordenar una tabla por un campo DATETIME.
Hago lo siguiente:
aFichAcc := "DBQ=C:\Fichero.mdb;Driver={Microsoft Access Driver (*.mdb)}"
RDDSETDEFAULT( "SQLMIX" )
IF RDDINFO( RDDI_CONNECT, { "ODBC", aFichAcc } ) == 1
DBUSEAREA( .T.,, "select * from Item", "aITem" )
INDEX ON FIELD->DtAlt TO Actual
ELSE
MSGINFO ("No he Podido Conectar." , "Error de Connexion" )
EndIF
Al ejecutar me dice:
Error SQLMIX/1026 Data Type error
Si modifico :
INDEX ON FIELD->HB_TTOS(DtAlt) TO Actual
Al Compilar me dice:
Error E0030 Syntax error "syntax error at '('"
Alguna Sugerencia??
-------------------------------------------------------------------------------------------------------------------------------------------------------------
I have a file access, and I need to sort a table by a DATETIME field.
I do the following:
aFichAcc := "DBQ=C:\Fichero.mdb;Driver={Microsoft Access Driver (*.mdb)}"
RDDSETDEFAULT( "SQLMIX" )
IF RDDINFO( RDDI_CONNECT, { "ODBC", aFichAcc } ) == 1
DBUSEAREA( .T.,, "select * from Item", "aITem" )
INDEX ON FIELD->DtAlt TO Actual
ELSE
MSGINFO ("No he Podido Conectar." , "Error de Connexion" )
EndIF
When you run it tells me:
SQLMIX Error / 1026 Data Type Error
If I change:
INDEX ON field-> HB_TTOS (DtAlt) TO Current
When compiling tells me:
E0030 Error Syntax error "syntax error at '('"
Any suggestions??
Index DateTime
Moderator: Rathinagiri
Index DateTime
Skydone Solutions
www.skydone.com
www.skydone.com
- vagblad
- Posts: 173
- Joined: Tue Jun 18, 2013 12:18 pm
- DBs Used: MySQL,DBF
- Location: Thessaloniki, Greece
Re: Index DateTime
I don't know if my solution will fit your coding style but that's what i always do when i am not working with pure SQL(MySQL,MS SQL,etc..):
1)Load all the data into an array with AAdd()
2)Sort the array with ASort()
3)Display data
So in your case if the datetime field goes into your array(with name aData) at let's say position[5] you could do :
So now you have all your data sorted the way you want and you can display - edit - search at your will.
Hope it helps
Best Regards
Google Translate
-------------------------------------------------------------------------
No sé si mi solución se ajuste a su estilo de codificación , pero eso es lo que siempre hago cuando no estoy trabajando con pura SQL ( MySQL , MS SQL , etc .. ) :
1 ) Coloque todos los datos en una matriz con AAdd ()
2 ) Clasificar la matriz con ASort()
3 ) los datos de visualización
Así que en su caso si el campo de fecha y hora entra en su conjunto (con nombre aData ) a digamos posición [ 5 ] que podía hacer :
Así que ahora usted tiene todos sus datos ordenados de la manera deseada y se puede mostrar - editar - búsqueda en tu voluntad.
Espero eso ayude
Atentamente
1)Load all the data into an array with AAdd()
2)Sort the array with ASort()
3)Display data
So in your case if the datetime field goes into your array(with name aData) at let's say position[5] you could do :
Code: Select all
ASort(aData,,,{|x , y| x[5] < y[5] }) for ascending
ASort(aData,,,{|x , y| x[5] > y[5] }) for descending
Hope it helps
Best Regards
Google Translate
-------------------------------------------------------------------------
No sé si mi solución se ajuste a su estilo de codificación , pero eso es lo que siempre hago cuando no estoy trabajando con pura SQL ( MySQL , MS SQL , etc .. ) :
1 ) Coloque todos los datos en una matriz con AAdd ()
2 ) Clasificar la matriz con ASort()
3 ) los datos de visualización
Así que en su caso si el campo de fecha y hora entra en su conjunto (con nombre aData ) a digamos posición [ 5 ] que podía hacer :
Code: Select all
ASort(aData,,,{|x , y| x[5] < y[5] }) para ascendente
ASort(aData,,,{|x , y| x[5] > y[5] }) para descender
Espero eso ayude
Atentamente
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
Email: vagblad@gmail.com, Skype: vagblad
- dragancesu
- Posts: 930
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: Index DateTime
I don't use Access, but indexing sql database is dificult than dbase. You can create index in Access. SQL use index if exist or create temporary, just use ORDER BY somefileld
Re: Index DateTime
Es que pasar todo a una array para luego ordenarlo, para eso lo tengo como ahora que reviso la tabla entera secuencialmente.
Porque como abririais un .mdb ?
---------------------------------------------------------
It is that it is an Array of call soon, that is why I like now I check the whole table sequentially.
Because as abririais. mdb?
Porque como abririais un .mdb ?
---------------------------------------------------------
It is that it is an Array of call soon, that is why I like now I check the whole table sequentially.
Because as abririais. mdb?
Skydone Solutions
www.skydone.com
www.skydone.com
Re: Index DateTime
Trata con esto...
INDEX ON FIELD->( HB_TTOS(DtAlt) ) TO Actual
ó
INDEX ON FIELD->( HB_TTOS(DtAlt) ) TAG test TO Actual
donde test es el nombre del indice y actual es el nombre del archivo. ( segun mis apuntes de FoxPro).
INDEX ON FIELD->( HB_TTOS(DtAlt) ) TO Actual
ó
INDEX ON FIELD->( HB_TTOS(DtAlt) ) TAG test TO Actual
donde test es el nombre del indice y actual es el nombre del archivo. ( segun mis apuntes de FoxPro).
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- Amarante
- Posts: 182
- Joined: Fri Apr 27, 2012 9:44 pm
- DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
- Location: Araruama-RJ, Brazil
Re: Index DateTime
Forgive me if I'm wrong, time does not use DBF files, but would not be correct HB_TTOS( Field->DtAlt )?
But also I think the best solution to dragancesu.
But also I think the best solution to dragancesu.
Re: Index DateTime
Hola Amarante
Creo que estas en lo correcto, pero si AidTIC (no sabemos su nombre) no sube un ejemplo y una DB de prueba...
AidTIC, si estas haciendo esto:
----------------------------------------------------------------------------------------------------------------------------------
Hello Amarante
I think you're right, but if AidTIC (do not know his name) does not raise an example and test DB ...
AidTIC, if you are doing this:
Creo que estas en lo correcto, pero si AidTIC (no sabemos su nombre) no sube un ejemplo y una DB de prueba...
AidTIC, si estas haciendo esto:
no necesitas poner FIELD->, a menos que tengas alguna variable con el mismo nombre.DBUSEAREA( .T.,, "select * from Item", "aITem" )
INDEX ON FIELD->DtAlt TO Actual
----------------------------------------------------------------------------------------------------------------------------------
Hello Amarante
I think you're right, but if AidTIC (do not know his name) does not raise an example and test DB ...
AidTIC, if you are doing this:
no need to put field->, unless you have a variable with the same name.DBUSEAREA (.T. ,, "select * from Item", "aITem")
INDEX ON field->DtAlt TO actual
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
Re: Index DateTime
Muchas gracias a todo, me ha funcionado la opcion de amarante.
Thanks everybody.
Thanks everybody.
Skydone Solutions
www.skydone.com
www.skydone.com