?
Solved

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

Posted on 2016-10-25
1
Medium Priority
?
50 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
[X]
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
1 Comment
 
LVL 51

Accepted Solution

by:
Vitor Montalvão earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.
Suggested Courses

801 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