ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sql query in excel (https://www.excelbanter.com/excel-programming/347221-sql-query-excel.html)

ivan

sql query in excel
 
im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!

Ron Coderre[_5_]

sql query in excel
 
Try this in your SQL code:
Date() as RunDate

Does that help?

***********
Regards,
Ron


"ivan" wrote:

im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!


ivan

sql query in excel
 
Thanks ron, but doesnt work, it says that cant show that query graphically

"Ron Coderre" wrote:

Try this in your SQL code:
Date() as RunDate

Does that help?

***********
Regards,
Ron


"ivan" wrote:

im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!


Ron Coderre[_5_]

sql query in excel
 
Ivan

Nothing's really wrong. That's just a notice from MS Query that it can't
represent the RunDate field in a table so it can't show you the query
graphically. From that point on, you'll need to edit the query via the SQL
window.

Does that help?

***********
Regards,
Ron


"ivan" wrote:

Thanks ron, but doesnt work, it says that cant show that query graphically

"Ron Coderre" wrote:

Try this in your SQL code:
Date() as RunDate

Does that help?

***********
Regards,
Ron


"ivan" wrote:

im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!


ivan

sql query in excel
 
i've tried but didnt work, i've tried with getday,now,etc

thanks a lot for your help

"Ron Coderre" wrote:

Ivan

Nothing's really wrong. That's just a notice from MS Query that it can't
represent the RunDate field in a table so it can't show you the query
graphically. From that point on, you'll need to edit the query via the SQL
window.

Does that help?

***********
Regards,
Ron


"ivan" wrote:

Thanks ron, but doesnt work, it says that cant show that query graphically

"Ron Coderre" wrote:

Try this in your SQL code:
Date() as RunDate

Does that help?

***********
Regards,
Ron


"ivan" wrote:

im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!


Ron Coderre[_5_]

sql query in excel
 
Perhaps if you posted a little more of your SQL code and told us what kind of
database (Oracle, MS Access, SQLServer, etc) you're accessing, we'd have a
better chance of helping.

***********
Regards,
Ron


"ivan" wrote:

i've tried but didnt work, i've tried with getday,now,etc

thanks a lot for your help

"Ron Coderre" wrote:

Ivan

Nothing's really wrong. That's just a notice from MS Query that it can't
represent the RunDate field in a table so it can't show you the query
graphically. From that point on, you'll need to edit the query via the SQL
window.

Does that help?

***********
Regards,
Ron


"ivan" wrote:

Thanks ron, but doesnt work, it says that cant show that query graphically

"Ron Coderre" wrote:

Try this in your SQL code:
Date() as RunDate

Does that help?

***********
Regards,
Ron


"ivan" wrote:

im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!


ivan

sql query in excel
 
this is the code
SELECT HelpDesk.Apellido, HelpDesk.Nombre, HelpDesk.Numero_de_Incidente,
HelpDesk.Fecha_de_Creacion, HelpDesk.Creado_por, HelpDesk.Assigned_to,
HelpDesk.Tipo_de_Problema, HelpDesk.Elem__Afectado, HelpDesk.Intervención
FROM HelpDesk HelpDesk
WHERE (HelpDesk.Fecha_de_Creacion={ts '2005-11-25 00:00:00'} And
HelpDesk.Fecha_de_Creacion<={ts '2005-11-26 00:00:00'}) AND
(HelpDesk.Estado<'Closed') AND (HelpDesk.Intervención<'Tarea Planificada')
AND (HelpDesk.Edificio<'Planta Chile')
ORDER BY HelpDesk.Apellido

i need to get the day i run the query.

can you help me?
Thanks a lot.

"Ron Coderre" wrote:

Perhaps if you posted a little more of your SQL code and told us what kind of
database (Oracle, MS Access, SQLServer, etc) you're accessing, we'd have a
better chance of helping.

***********
Regards,
Ron


"ivan" wrote:

i've tried but didnt work, i've tried with getday,now,etc

thanks a lot for your help

"Ron Coderre" wrote:

Ivan

Nothing's really wrong. That's just a notice from MS Query that it can't
represent the RunDate field in a table so it can't show you the query
graphically. From that point on, you'll need to edit the query via the SQL
window.

Does that help?

***********
Regards,
Ron


"ivan" wrote:

Thanks ron, but doesnt work, it says that cant show that query graphically

"Ron Coderre" wrote:

Try this in your SQL code:
Date() as RunDate

Does that help?

***********
Regards,
Ron


"ivan" wrote:

im triyn to retrieve data to excel with the microsoft query
can you help me with the function to get the day i run the query?

get day() doesnt work.

a query error appears!


DM Unseen

sql query in excel
 
There are 2 ways to solve this:

create a new column in your select clause that gives the current
day/time. The function to do this depends on the DBMS. e.g. for SQL
server this is "getdate()"

so "Select getdate() as CurrentDate, ...... from ...." would work on
SQL Server.

If your query gives more that 1 record you will see the date for each
line (maybe not want you want).

With VBA it would look something like this:

In Thisworkbook module:

Dim Withevents qtb as QueryTable

Sub Workbook_Open

Set qtb = Thisworkbook.Sheets("Mysheet").QueryTables("Mytabl e")

End Sub


qtb_AfterRefresh(bSuccess as boolean)

if bSuccess then Range("Mysheet!A1") = Now()

End Sub

This code would update A1 with current date after a succesful refresh.


DM Unseen


ivan

sql query in excel
 
Thanks for the info, the problem is i am working with remedy.
There i can use $date$ to replace the day but doesnt work in the microsoft
query

"DM Unseen" wrote:

There are 2 ways to solve this:

create a new column in your select clause that gives the current
day/time. The function to do this depends on the DBMS. e.g. for SQL
server this is "getdate()"

so "Select getdate() as CurrentDate, ...... from ...." would work on
SQL Server.

If your query gives more that 1 record you will see the date for each
line (maybe not want you want).

With VBA it would look something like this:

In Thisworkbook module:

Dim Withevents qtb as QueryTable

Sub Workbook_Open

Set qtb = Thisworkbook.Sheets("Mysheet").QueryTables("Mytabl e")

End Sub


qtb_AfterRefresh(bSuccess as boolean)

if bSuccess then Range("Mysheet!A1") = Now()

End Sub

This code would update A1 with current date after a succesful refresh.


DM Unseen



DM Unseen

sql query in excel
 
Is the $date$ function available through ODBC drivers? if so this might
be an issue with MSQuery.

Maybe edit your query directly through VBA or another tool?

I not, use the VBA solution.

Dm Unseen



All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com