We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,519 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Date filter

The date stored in my db is in the following format:

2011-06-10 17:15:26.000
2011-06-10 17:15:27.000
2011-06-10 17:15:28.000
2011-06-10 17:15:29.000

However I intend to retrieve the date above using the format below:

2011-06-10

How is it done?

Your help is kindly appreciated.

2
Contributors
3
Replies
15 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
solomon_13000
Junior Poster
114 posts since Jul 2009
Reputation Points: 24
Solved Threads: 0
Skill Endorsements: 0
SELECT CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]

For details refer following link
http://www.sql-server-helper.com/tips/date-formats.aspx

urtrivedi
Posting Virtuoso
1,714 posts since Dec 2008
Reputation Points: 299
Solved Threads: 362
Skill Endorsements: 24

When I perform a filteration using the code below I do not see any results.

select  
                    a.id as 'id', 
                    a.adjust as 'adjust', 
                    a.counter as 'counterCode',  
                    c.name as 'counterName', 
                    a.clientName as 'clientName', 
                    a.loginId as 'loginId', 
                    a.exchRate as 'exchRate', 
                    a.filledQty as 'filledQty', 
                    a.ordStatus as 'ordStatus', 
                    a.price as 'price', 
                    a.quantity as 'quantity', 
                    a.remark as 'remark', 
                    a.settCurr as 'settCurr', 
                    tradCurr=isNull(c.currency, b.currency),  
                    a.traderCode as 'traderCode', 
                    a.tradingAccNo as 'tradingAccNo', 
                    a.transType as 'transType', 
                    a.createdDate as 'createdDate',
                    b.id as 'exchId', 
                    b.name as 'exchCode' 
                    from rm_markettransaction a 
                    left join RM_Exchange b 
                    on a.rm_exchange_fk = b.id 
                    left join RM_Counter c 
                    on c.code = a.counter 
                    where b.srcType='offline' and a.createdDate = '2011-06-10'
solomon_13000
Junior Poster
114 posts since Jul 2009
Reputation Points: 24
Solved Threads: 0
Skill Endorsements: 0

When you are not using code posted by me then how you can expect result. use following query

select  
                    a.id as 'id', 
                    a.adjust as 'adjust', 
                    a.counter as 'counterCode',  
                    c.name as 'counterName', 
                    a.clientName as 'clientName', 
                    a.loginId as 'loginId', 
                    a.exchRate as 'exchRate', 
                    a.filledQty as 'filledQty', 
                    a.ordStatus as 'ordStatus', 
                    a.price as 'price', 
                    a.quantity as 'quantity', 
                    a.remark as 'remark', 
                    a.settCurr as 'settCurr', 
                    tradCurr=isNull(c.currency, b.currency),  
                    a.traderCode as 'traderCode', 
                    a.tradingAccNo as 'tradingAccNo', 
                    a.transType as 'transType', 
                    a.createdDate as 'createdDate',
                    b.id as 'exchId', 
                    b.name as 'exchCode' 
                    from rm_markettransaction a 
                    left join RM_Exchange b 
                    on a.rm_exchange_fk = b.id 
                    left join RM_Counter c 
                    on c.code = a.counter 
                    where b.srcType='offline' and CONVERT(VARCHAR(10), a.createdDate, 120) = '2011-06-10'
urtrivedi
Posting Virtuoso
1,714 posts since Dec 2008
Reputation Points: 299
Solved Threads: 362
Skill Endorsements: 24

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0632 seconds using 2.68MB