[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB.Net - Query to compare Datetime in SQL Server

Posted on 2013-12-27
1
Medium Priority
?
601 Views
Last Modified: 2014-01-11
Good Day Experts!

I struggle much with comparing dates from my SQL Server db.  

I have 2 tables with date fields.  One is smalldatetime/4 with no time 2013-12-17 00:00:00. The other is datetime/8 with time 2013-12-17 07:19:04.300.

Field 1 does not get populated with the time.  So, when I compare the 2 fields if the dates are the same I need Field 2 to be greater since it has a time on it.

Can I do that? Do you have any resource sites that can help me achieve this?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[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 13

Accepted Solution

by:
Jesus Rodriguez earned 2000 total points
ID: 39742716
Do a datediff DateDiff(MM.@date1,@Date2) and if is >0 then Daate1>Date2

look this example
SELECT DATEDIFF(MINUTE,'2011-09-23 18:03:23','2011-09-23 17:15:30')

For more info look and run this query in your sql and you will see

select cast(getdate() as datetime)
select cast(getdate() as date)
SELECT DATEDIFF(MINUTE,cast(getdate() as date),cast(getdate() as datetime))

You can replace the getdate() function with Table1.Field1 for the first getdate() and Table2.Field1 for the second getdate()
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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