Thean S
asked on
getdate in between condition - MS SQL Server
Hi
Can you please tell me how to use getdate:00:00:00 and getdate:11:59:00 in SQL between condition
select count(*) from tablename where createdon between 'getdate:00:00:00' and 'getdate:11:59:00'
thanks in advance
Can you please tell me how to use getdate:00:00:00 and getdate:11:59:00 in SQL between condition
select count(*) from tablename where createdon between 'getdate:00:00:00' and 'getdate:11:59:00'
thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try
select * from tab0 where CONVERT(varchar,datecolumn,112)=CONVERT(varchar,getdate(),112)
ASKER
--
>> CONVERT(varchar,datecolumn ,112)
This one will make the indexes to go for scan instead of seek if any available on that particular column..
hence this will have some performance issues.
>> I have another issue with count that I have raised in below link
Sure, let me check now..
This one will make the indexes to go for scan instead of seek if any available on that particular column..
hence this will have some performance issues.
>> I have another issue with count that I have raised in below link
Sure, let me check now..
Try the way below to trucate the date by removing the time:
select * from tab0 where CONVERT(DATETIME, CONVERT(DATE, datecolumn))=CONVERT(DATETIME, CONVERT(DATE, GETDATE()))
ASKER
Hi Raja and HuaMin Chen,
Thanks for your help on this.
I have raised another question for my issue. Can you please help on this.
https://www.experts-exchange.com/questions/29129054/Problem-with-SQL-command-MS-SQL-Server.html?headerLink=workspace_open_questions
Thanks for your help on this.
I have raised another question for my issue. Can you please help on this.
https://www.experts-exchange.com/questions/29129054/Problem-with-SQL-command-MS-SQL-Server.html?headerLink=workspace_open_questions
ASKER
I have another issue with count that I have raised in below link. Can you please help me to fix my problem.
Link: https://www.experts-exchange.com/questions/29128960/help-required-on-MS-SQL-query.html?headerLink=workspace_open_questions
Subject: help required on MS SQL query