Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can i compare the date field with sql get date function

Posted on 2016-10-25
1
35 Views
Last Modified: 2016-10-25
Hi Experts ,

I want to get all the rows with today date and select only those data . I have a field called Startdate . i want to compare those value with todays date using sql function and return todays date data only

SQL Query i tried
select ms.Id, ms.MailTemplate, ms.EmailAddress, ms.SchedulerName, ms.Module, ms.CustomViewId, ms.StartDateTime, ms.IsActive,mt.EmailBody, mt.TemplateName,mt.EmailSubject, v.ViewName from MailScheduler ms join MailTemplate mt on mt.Id=ms.MailTemplate join [Views] v on v.ID= ms.CustomViewId where ms.StartDateTime = GETDATE()  order by ms.Id desc 

Open in new window


Please see the attached screenshot
Thanks in Advance Experts
Capture.PNG
0
Comment
Question by:karthik80c
1 Comment
 
LVL 48

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41858418
If your StartDateTime can't be higher than today then use the following:
select ms.Id, ms.MailTemplate, ms.EmailAddress, ms.SchedulerName, ms.Module, ms.CustomViewId, ms.StartDateTime, ms.IsActive,mt.EmailBody, mt.TemplateName,mt.EmailSubject, v.ViewName 
from MailScheduler ms 
    join MailTemplate mt on mt.Id=ms.MailTemplate 
    join [Views] v on v.ID= ms.CustomViewId 
where ms.StartDateTime >= CAST(GETDATE() AS DATE)
order by ms.Id desc 

Open in new window

1

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question