January 25, 2016 at 8:04 am
This is run with a string in VS 2012, the database table is a mdb (access):
Dim SQLStringtempprd123 As String = "SELECT CAST([create_dtim],'dd-mm-yyyy'),COUNT(*) AS tot FROM Back_ickpt_prd1 WHERE CAST([create_dtim],'dd-mm-yyyy') between '01-09-2016 00:00:01' and '05-01-2016 23:59:01' GROUP BY CAST([create_dtim],'dd-mm-yyyy') order by CAST([create_dtim],'dd-mm-yyyy') desc "
and the error is not detailed but it's a syntax error!
:crying:
JC
January 25, 2016 at 8:09 am
Of course, there's a syntax error as you're following the FORMAT syntax instead of the CAST syntax.
January 25, 2016 at 8:09 am
jcachado (1/25/2016)
This is run with a string in VS 2012, the database table is a mdb (access):
Dim SQLStringtempprd123 As String = "SELECT CAST([create_dtim],'dd-mm-yyyy'),COUNT(*) AS tot FROM Back_ickpt_prd1 WHERE CAST([create_dtim],'dd-mm-yyyy') between '01-09-2016 00:00:01' and '05-01-2016 23:59:01' GROUP BY CAST([create_dtim],'dd-mm-yyyy') order by CAST([create_dtim],'dd-mm-yyyy') desc "
and the error is not detailed but it's a syntax error!
:crying:
JC
This is the SQL Server 2012 forum section.
Try posting in the Access section. Or perhaps Luis can help with Access.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 25, 2016 at 8:15 am
Luis Cazares (1/25/2016)
Of course, there's a syntax error as you're following the FORMAT syntax instead of the CAST syntax.
Worth a try:
Dim SQLStringtempprd123 As String = "SELECT CAST([create_dtim] AS DATE), COUNT(*) AS tot FROM Back_ickpt_prd1 WHERE CAST([create_dtim] AS DATE) between '01-09-2016 00:00:01' and '05-01-2016 23:59:01' GROUP BY CAST([create_dtim] AS DATE) order by CAST([create_dtim] AS DATE) desc"
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 25, 2016 at 8:23 am
ChrisM@Work (1/25/2016)
jcachado (1/25/2016)
This is run with a string in VS 2012, the database table is a mdb (access):
Dim SQLStringtempprd123 As String = "SELECT CAST([create_dtim],'dd-mm-yyyy'),COUNT(*) AS tot FROM Back_ickpt_prd1 WHERE CAST([create_dtim],'dd-mm-yyyy') between '01-09-2016 00:00:01' and '05-01-2016 23:59:01' GROUP BY CAST([create_dtim],'dd-mm-yyyy') order by CAST([create_dtim],'dd-mm-yyyy') desc "
and the error is not detailed but it's a syntax error!
:crying:
JC
This is the SQL Server 2012 forum section.
Try posting in the Access section. Or perhaps Luis can help with Access.
I only use Access... cards to enter buildings. :hehe:
A quick Google search suggest to use one of these:
DateValue([create_dtim])
Cdate(int([create_dtim]))
That's what happens when you use a forum for SQL Server to ask questions about other databases.
January 25, 2016 at 8:25 am
I appreciate your help but still not running.
:crying:
JC
January 25, 2016 at 11:25 am
Hi again,
I fix this with this.
CDate(Format(Campo,"dd-mm-yyyy"))
Thks a lot for your help,
Regards,
JC
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply