Solved

error on query datetime by month

Posted on 2014-03-27
2
127 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
  • 2
2 Comments
 
LVL 25

Accepted Solution

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

Open in new window

0
 
LVL 25

Expert Comment

by:Lee Savidge
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
t-sql complement 8 29
Backup Job question 4 17
Sort by Month and Year - SQL 3 22
Complex SQL 10 32
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now