473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Date from datetime

52
Hello!

This is probably easy, but i'm a noob and couldn't find the answer by searching...

I'm trying to run a search query on my database that will get all entrys for a specified date.

this is the statement i have so far

SELECT *
FROM dbo.CLM
WHERE Date = '7/10/2007'

(I will be using ASP to make the date dynamic)

Even though all of my entries are from that date, it pulls up nothing. Where am I going wrong here?
Jul 17 '07 #1
4 1574
HI
i am also a beginne so i may not help u so much but what i know is that:
when you say date ='7/10'2007' it i sjust givinig you the entries for that date not before or after that date.
have alook to see what is the name of that column for the date. you have to put the name of that column and if you want all the entries after that you have to put date=>''7/10/2007'
and also check the format of your date. is it 7-10-2007 or 7 oct 2007 or 10 jul 07.
i hope i be right and can help u.
voroojak
Jul 18 '07 #2
Shisou
52
Thanks for the advise but that's not quite what i'm looking for.

I do only want it to pull up dates from that one specified day. The column name is Date and the date entry looks like this

7/10/2007 3:51:01 PM it is a datetime value

when i run the query posted above it doesn't return anything.

not sure what i'm doing wrong here..
Jul 18 '07 #3
DonlonP
25
Hello!

This is probably easy, but i'm a noob and couldn't find the answer by searching...

I'm trying to run a search query on my database that will get all entrys for a specified date.

this is the statement i have so far

SELECT *
FROM dbo.CLM
WHERE Date = '7/10/2007'

(I will be using ASP to make the date dynamic)

Even though all of my entries are from that date, it pulls up nothing. Where am I going wrong here?
In SQL when you compare a datetime field to '7/10/2007' it converts it to a datetime of 2007-10-07 00:00:00.000. Therefore your query is looking for records at exactly that date. What you need to do is:

WHERE Date => '7/10/2007' AND < DATEADD(DAY, 1, '7/10/2007')

i.e. look for records between 2007-10-07 00:00:00.000 and 2007-10-08 00:00:00.000.
Jul 18 '07 #4
I think you can use one of these methods.

1)where date>= '7/10/2007' and date <'8/10/2007'
and also you can use
2) where date like '7/10/2007'



3) where
datepart(year, date)='2007' AND
datepart(month, date)= '10' AND
datepart(day, date)='7'

i think it should work.
Jul 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: Harald Hanche-Olsen | last post by:
I'm confused. I was going to try linkchecker, and it dies with a traceback ending in File "/usr/local/lib/python2.4/calendar.py", line 32, in _localized_month _months = AttributeError:...
4
by: Russell | last post by:
I'm having a fit with a query for a range of dates. The dates are being returned from a view. The table/field that they are being selected from stores them as varchar and that same field also...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
6
by: MarkAurit | last post by:
Im having difficulty coming up with a good algorithm to express the following comparison: "if <a given date> falls between the (current date - 5 days) and the (current date)" Obviously....
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
10
by: kyosohma | last post by:
Hi, I am working on a timesheet application in which I need to to find the first pay period in a month that is entirely contained in that month to calculate vacation time. Below are some example...
2
by: Andrus | last post by:
I need to display and edit only date part in DataGridView column whose data source type is DateTime?. The following code shows and allows to edit also time part. How to modify this code so that...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.