473,379 Members | 1,222 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,379 software developers and data experts.

Date Problem

hi,
i'm using vb.net 2003 and sql server 2000. i have created one table named
tblYear
create table tblYear
(
sntYearCode smallint,
datFrom datetime,
datTo datetime,
);
i inserted values below
insert into tblYear(sntYearCode,datFrom,datTo) values (1,'2009-04-01','2010-03-31')
insert into tblYear(sntYearCode,datFrom,datTo) values (2,'2010-04-01','2011-03-31')
insert into tblYear(sntYearCode,datFrom,datTo) values (3,'2011-04-01','2012-03-31')
insert into tblYear(sntYearCode,datFrom,datTo) values (4,'2012-04-01','2013-03-31')



select sntYearCode from tblYear where datfrom >= '2009-07-24 ' and
datto <= '2009-07-24'

if i execute the query , my Result should be 1 but i'm not getting..

it's urgent..
Thanx in Adv.

Ganesh
Apr 7 '09 #1
4 993
MrMancunian
569 Expert 512MB
I think it might have something to do with the fact that you created two datetime fields, but you're only checking the date. Another thing you can think of is the local datetime settings on both the server and your PC...

Do you get an error or doesn't it return a value?

Steven
Apr 7 '09 #2
hi steven,
thanx for u'r reply.
i'm not getting any return value.

ganesh
Apr 8 '09 #3
MrMancunian
569 Expert 512MB
Not getting a return value probably means that your query isn't correct. Try to change this line:

Expand|Select|Wrap|Line Numbers
  1. select sntYearCode from tblYear where datfrom >= '2009-07-24 ' and datto <= '2009-07-24'
to this:

Expand|Select|Wrap|Line Numbers
  1. select sntYearCode from tblYear where datfrom >= '2009-07-24 00:00:00' and datto <= '2009-07-24 23:59:59'
As you defined you tablecolumns as datetime, I can imagine that it want to have both date and time, instead of date only.

Steven

P.S. Did you copy your code directly from your project? If so, there is an empty space between the first 24 and the quote. You should fix that, as it is a string, and it won't be trimmed.
Apr 8 '09 #4
aryanbs
42
Your comparsion is wrong, should be this

select sntYearCode from tblYear where datfrom <= '2009-07-24' and
datto >= '2009-07-24'
Apr 8 '09 #5

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

Similar topics

1
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime...
7
by: martini | last post by:
Need help: I am trying to call a DB2 stored procedure that requires parameters: 4x int, date, varchar, int. I use VB6 & oledb. I'm using statements: cmd.CommandText = "{call db2admin.proc(1, 0,...
11
by: David B | last post by:
I have 2 querys with the following in the date criteria Between DateAdd("m",-6,(!!)) And (!!) Between DateAdd("m",-24,(!!)) And DateAdd("m",-6,(!!)) Problem is they both look at the same...
3
by: Dustin Wilson | last post by:
I have a problem with the following line of code. rstOutput! = FormatDateTime("January 1, 2004", vbLongDate) When I run this on my computer at home it runs without problem but when I run it at...
3
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not...
2
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result....
1
by: TN Bella | last post by:
Hello, I was looking through the older posts for a solution to this problem, but I am still confused on how to fix my problem. There are two dates on my form, one (txtInvDate) is entered by the...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
7
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.