473,763 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datepart query example help needed or something else??

The field itemdate is a datetime field in sqlserver2000 DB

This works fine:
Select Id From BookData Where (MONTH(itemdate ) = '01') and
(DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') order by
TitleDuplicate

This does not work:
Select Id From BookData Where (MONTH(itemdate ) = '01') and
(DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') and (datepart(Hh,
itemdate) = '06') and (datepart(Mi, itemdate) = '17') and (datepart(Ss,
itemdate) = '15') order by TitleDuplicate

It returns zero records even though the datetime field has a record
with the datetime value in it of:
1/2/2005 6:17:15 PM

I tried a bunch of different things like datepart(hh,ite mdate) ='6'"
etc...

the DB script for this datetime field sets it as:
"ItemDate DATETIME DEFAULT '',"

Any ideas on what is going on or what am I missing ?
Thanks for any help you can give.

Jul 23 '05 #1
2 4501
Where convert(varchar (8),itemdate,11 2) = '20050102'
and convert(varchar (8),itemdate,10 8) = '06:17:15'

Note - the datepart valuse you have are int's not chars.

Nigel Rivett
www.nigelrivett.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #2
It is solved!
My own fault for not thinking of a 24 hour clock.
The hours I should have tried was 18 not 6 . I was thinking 6 AM when
it was 6
PM. It really had me bugged out
The code was working all along.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6306
by: David | last post by:
Hi Group, i am trying to use the DatePart function on my SQL2000 database. I have a table called visitors with a field called DateTimeEntrance which is filled everytime a visitor enters the site. I am trying to build a stat page where i display the total amount of visitors per day, week, month, year and i can't seem to get the syntax correct. I get an error with the following code: sql = "SELECT * FROM tblVisitors WHERE...
20
10161
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
22
3066
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20 3, NULL, 9, 82, 25
8
8623
by: Bri | last post by:
Greetings, I am using Eval() in a query with only limited success. If the text within the function contains a reference to a Field I get #ERROR#. I'll try and explain what I'm trying to do and maybe one of you can either tell me how to get the Eval() to work or suggest and alternate method. I have a table called Units: Fields: Unit, Formula Sample Data:
3
2291
by: funfair | last post by:
Hi, I'm facing a strange problem in access 2003 i dont know how to solve it i have a code in VB which give an autonumber but in finanical new year it reset to 1 on new year it works in one form but the same code doesnt work in other form in run time it's going to skip if satatement of date part to check if month is 4 or not what is the problem ? i have looked in the net and i read somehting about reference what should i do about it .
3
1963
by: cover | last post by:
I have a table with 50 fields that receive input depending on whether that input came in from a 'shaker' form or a 'conveyor' form. Input from the 'conveyor' form might populate 25 fields while input from the 'shaker' form will populate another 20-25 fields but not the same fields (however there are about 10 common fields to both). I'd thought about using two tables (one for 'conveyor' and the other for 'shaker') but thought I'd try just...
2
6796
by: troddy | last post by:
I am using the DatePart funtion in a query to extract the day, month and year in separate fields in a query. The function works fine but I am only getting a number for the month even if the field type is a long date and the month is stored in the table. I tried the following to try and get the name of the month to work. DateTest: Format(DatePart("m",),"mmmm") The DateAffirmed field had a date stored of 16/03/2006.
2
2138
by: le0 | last post by:
Hello guys, Is there anything wrong with my code (see below) bcoz when 10p-6a shift my browser returns the error cannot be a zero-length string. Im wondering why, bcoz the 2 other shift works perfectly. <% 'Shift: 6a-2p if DatePart("h", Now()) 5 And DatePart("h", Now()) < 14 then ShiftID = "A"
3
3621
by: grabit | last post by:
Hi Peoples I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007 i have 2 drop down boxes to select the listedmonth and listedyear on the refering page I need to be able to retrieve this so i can send out renewals to those listings for another year. I am using this query <cfquery name="getrenew" datasource="#dsn#"> SELECT datelisted FROM listings WHERE...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.