Solved

error on query datetime by month

Posted on 2014-03-27
2
132 Views
Last Modified: 2014-03-27
select frmRegistrationCSWText1, count(Distinct ID) from frmRegistrationCSW where entrytime = 'january' group by frmRegistrationCSWText1

I get the following error after running the above code:
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.

How do I specifiy entrytime correctly.  datatype is datetime for that entrytime
0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 500 total points
ID: 39959543
where datename(m, entrytime) = 'january'

Open in new window

0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39959550
You could always just use the month number:

where month(entrytime) = 1

Open in new window


Neither option of course, takes the year into account.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question