OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

SQL query by Date- Problems

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> SQL query by Date- Problems
Page: [1]
 
dupati1

 

Posts: 84
Joined: 10/6/2003
Status: offline

 
SQL query by Date- Problems - 10/8/2003 13:13:52   
Hi All,

How can I retrieve the data based on the date. I need to retrieve all the records newer than the date 2003-09-30;

I used

SELECT * FROM vw_Absence_Report WHERE StartDate > '2003-09-30';

//vw_Absence_Report is a view formed by using other tables of the database

But doesnt work:



I get this error message:

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Incorrect syntax near the keyword 'Where'.
/departments/human_resources/employee_absence/admin/reportgenerator.asp, line 61


The StartDate column in the SQL Server table has the values of the form

YYYY-MM-DD 00:00:00:000. I mean it’s a datetime field.



I also tried other variations of SQL query like:



SELECT * FROM vw_Absence_Report WHERE StartDate > #2003-09-30#;

SELECT * FROM vw_Absence_Report WHERE StartDate > '2003-09-30 00:00:00.000';

SELECT * FROM vw_Absence_Report WHERE StartDate > #2003-09-30 00:00:00.000#;


But none of them worked.

Any suggestions??

VJ
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: SQL query by Date- Problems - 10/8/2003 15:07:42   
Did you try:

SELECT * FROM vw_Absence_Report WHERE StartDate > '2003/09/30'

_____________________________


(in reply to dupati1)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: SQL query by Date- Problems - 10/8/2003 21:40:27   
I am not at work to check this, but if I recall correctly, there should be no characters around your date. I think it is simply this:

SELECT * FROM vw_Absence_Report WHERE StartDate > 2003/09/30

(in reply to Long Island Lune)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: SQL query by Date- Problems - 10/8/2003 22:22:13   
Have you tried writing the SQL string?

eg:

response.write SQL
Response.end

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
dupati1

 

Posts: 84
Joined: 10/6/2003
Status: offline

 
RE: SQL query by Date- Problems - 10/9/2003 9:24:14   
Thanks All,

Thanks for your suggestions. Finally i solved problem. As i said that vw_Absence_Report was a view that i was using in my SQL statement, i dont know why ASP SQL cannot reference to the views when trying for some variations..

I tried to run the query
SELECT * FROM vw_Absence_Report WHERE StartDate > '2003-09-30'
in the query analyzer and it worked fine.

so then i decided to create a new view which contained only the newer records new than 2003-09-30 and then i referenced this view on the ASP page as

SELECT * FROM vw_newAbsence_Report

Then it worked fine.

But still i am not sure why the previous sql statement did not work.

Thanks

Vijay

(in reply to dupati1)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: SQL query by Date- Problems - 10/9/2003 12:48:59   
Hi Dupati1,

Did you mean in your original SQL?

quote:

SELECT * FROM vw_Absence_Report WHERE StartDate > '2003-09-30'

The reason it didn't work was because you used "-"; ('2003-09-30') instead of "/"; '2003/09/30' in your date. If that's what you meant...

:)

_____________________________


(in reply to dupati1)
dupati1

 

Posts: 84
Joined: 10/6/2003
Status: offline

 
RE: SQL query by Date- Problems - 10/9/2003 14:15:45   
Nope,

even '2003/09/30' did not work. It only worked when i created a new view and referenced it in the query.

Thanks

Vijay

(in reply to Long Island Lune)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> SQL query by Date- Problems
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts