Solved

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

Posted on 2016-10-25
1
39 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 49

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

733 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