tags:

views:

150

answers:

5

this is what i want. but i have put only a specified date.

SELECT BookName, Author, BookPrice 
FROM Book 
WHERE Book.Book_ID = ( 
    SELECT Book_ID 
    FROM Temp_Order 
    WHERE Temp_Order.User_ID = 25 AND Temp_Order.OrderDate='3/24/2010'
)

this is the date function i used. but it takes the time also. how to stop it. please help me

SELECT Book_ID, BookName,Author,BookPrice 
FROM Book INNER JOIN FavCategory ON Book.Category_ID = FavCategory.Category_ID 
WHERE FavCategory.User_ID = " + useridlabel.Text + " AND 
      OrderDate =  **GETDATE()** 
+2  A: 
SELECT CONVERT (date, GETDATE())

MSDN

Rorschach
thank you for the quick messagei found thisCONVERT (date, GETDATE())but in here what is 'date'? is it the column name . can please explain to me
Nubkadiya
is a datatype that comes in with Sql Server 2005 and above
Jhonny D. Cano -Leftware-
SELECT BookName, Author, BookPrice FROM Book WHERE Book.Book_ID = ( SELECT Book_ID FROM Temp_Order WHERE Temp_Order.User_ID = 25 AND Temp_Order.OrderDate= CONVERT (date, GETDATE()))This is the msg i getMsg 243, Level 16, State 1, Line 1Type date is not a defined system type.
Nubkadiya
sorry, SQL 2008 "and above" http://msdn.microsoft.com/en-us/library/ms187752%28SQL.90%29.aspx
Jhonny D. Cano -Leftware-
+2  A: 

This one is for Sql Server 2000:

SELECT CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, GETDATE())))
Jhonny D. Cano -Leftware-
A: 

Try:

  OrderDate =  CONVERT(varchar, GETDATE(), 101)

wich returns the date in format mm/dd/yyyy, or choose a convertion format from here.

eKek0
Hi Friends, Thanks for all the comments. Is there anyway when i insert the Date. without sending the time. only the date will get saved. even if i do that it will save the time as 12.00. is there anyway for that? if i can find that i can solve my problem too
Nubkadiya
No, you will have to save the date and the time, since there is no date type. You will have to convert always the datetime to date using convert to work with it as if it was a date.
despart
A: 

This is a classic question for Sql Server versions previous 2008:

SELECT Book_ID, BookName,Author,BookPrice 
FROM Book INNER JOIN FavCategory ON Book.Category_ID = FavCategory.Category_ID 
WHERE FavCategory.User_ID = " + useridlabel.Text + " 
AND CONVERT(nvarchar, OrderDate, 111) = CONVERT(nvarchar, GETDATE(), 111)

Depending on the code (111) you put at the end you can format the date for the zone where you are.

despart
thanks a lot. thanks.
Nubkadiya
A: 
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
LukeH