SQL string syntax problem

radek225

Registered User.
Local time
Today, 12:15
Joined
Apr 4, 2013
Messages
307
I have problem to implement "short date" in format to sqlstring
(syntax)
what's wrong with my sqlstring? Ms Access shows me that is something wrong with "short date" part

Code:
    strsqLy = "select datarozpoczecia, datazakonczenia from " & _
    "tblPRocesyZleceniaSzczegoly inner join (tblZmianySzczegoly inner join tblZmiany on tblZmianySzczegoly.id_zmiany = tblZmiany.id_zmiany) " & _
    "on tblProcesyZleceniaSzczegoly.pracownik = tblZmianySzczegoly.pracownik " & _
    "where format(#datazmiany#, "short date")=#" & Format(#Now()#, "short date") & "# and nz(datarozpoczecia, 0)>" & 0 & " and nz(datazakonczenia, 0)=" & 0
 
You don't want the # inside the Format() function for starters.
 
The double quotes in the first need to be singles; the doubles close out the string.
 
Functions like Format or Nz have to be concatenated into the string. When you are forming this type of SQL string use the intellisense to see if you are on the right track. For example when you typed:

"where format(

the intellisense should have kicked in. It didn't because you were still in a string. If you type

"where " & format(

you will see what I mean. I suggest reading

http://www.techonthenet.com/access/functions/string/concat.php

too.
still I do not know how my link should look like:/
 
still can't write this string properly:/. Guys any ideas?
 
I'll be generous
strsqLy = "select datarozpoczecia, datazakonczenia from " & _ "tblPRocesyZleceniaSzczegoly inner join (tblZmianySzczegoly inner join tblZmiany on tblZmianySzczegoly.id_zmiany = tblZmiany.id_zmiany) " & _ "on tblProcesyZleceniaSzczegoly.pracownik = tblZmianySzczegoly.pracownik " & _ "where format(datazmiany, 'short date')=#" & Format(Now(), "short date") & "# and nz(datarozpoczecia, 0)>0 and nz(datazakonczenia, 0)=0"
 
I'll be generous
strsqLy = "select datarozpoczecia, datazakonczenia from " & _ "tblPRocesyZleceniaSzczegoly inner join (tblZmianySzczegoly inner join tblZmiany on tblZmianySzczegoly.id_zmiany = tblZmiany.id_zmiany) " & _ "on tblProcesyZleceniaSzczegoly.pracownik = tblZmianySzczegoly.pracownik " & _ "where format(datazmiany, 'short date')=#" & Format(Now(), "short date") & "# and nz(datarozpoczecia, 0)>0 and nz(datazakonczenia, 0)=0"

Thanks for your help. Now it works:) :)
 

Users who are viewing this thread

Back
Top Bottom