Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.17/5 (3 votes)
See more:
SQL
token no state	ppo_no          name            sec     billdate                amount  status    
7	CCV	11915		KUNDAN LAL	PAO5	15/05/2014 12:45:53 PM	2000	DH
6       ccv      11358          nand lal        pao5    13/05/2014              5000    dh



i want to retrieve token no when bill date 15/05/2014 and my system date is also 15/05/2014


please help me
Posted
Updated 15-May-14 0:12am
v2
Comments
King Fisher 15-May-14 6:18am    
what's your billdate column datatype?
tanugarg 15-May-14 6:20am    
datetime

Hello,

Do you want to retrieve the tokens having bill date as today (today is nothing but the system date) or is it always going to be 15/05/2014? If you want to retrieve tokens for today and assuming that the data type for bill_date column is datetime then you can use following SQL
SQL
SELECT * FROM YOUR_TABLE 
WHERE CONVERT(DATE, bill_date, 112) = CONVERT(DATE, GETDATE(), 112)

Regards,
 
Share this answer
 
Comments
tanugarg 15-May-14 6:43am    
THIS QUERY IS NOT WORKING
Prasad Khandekar 15-May-14 7:45am    
You get now records or wrong records or error? You must have replaced YOUR_TABLE with the actual table name right?
Convert both values and even use other cool feature of CONVERT() function to give it formatting and see what happens
SQL
CREATE PROCEDURE usp_Token 
 (@systemdate datetime )
AS
BEGIN
	SELECT [token no] FROM table_name FROM dbo.SalesOrder
WHERE CONVERT(VARCHAR, billdate ,112) = CONVERT(VARCHAR, @systemdate ,112);

END
 
Share this answer
 
v2
Comments
tanugarg 15-May-14 6:26am    
but this code shows Must declare the variable '@systemdate'.
[no name] 15-May-14 6:27am    
I hope you are using storeprocedure if not you can use direct there your system date value
tanugarg 15-May-14 6:38am    
please explain it how i declare
[no name] 15-May-14 7:09am    
see it's updated

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900