Advertisement

05.23.2008 at 10:34AM PDT, ID: 23428342
[x]
Attachment Details

DateDiff Minute GetDate Between C# vs SQL

Asked by kvnsdr in MS SQL Server

I've been using the following C#/SQL combo to get a solution. It works as-is but I would like to have a pure-SQL solution if possible.

[C#/SQL Combo]
string strCurrentTimeOnly = DateTime.Now.ToShortTimeString(); // 10:17 AM
string strDayofWeek = DateTime.Now.DayOfWeek.ToString(); // Thursday
                   
string sql = " Select * from tbl_Users where col3 = 'True' " +
" and DateDiff(n, col_TimeOnly, '" + strCurrentTimeOnly + "') between 1 and 1 " +
" Or col_DayOfWeek = '" + strDayOfWeek + "')";

[SQL using GetDate()]
" Select * from tbl_Users where col3 = 'True' " +
" and DateDiff(minute, col_TimeOnly, GetDate()) between 1 and 1 " +
" Or col_DayOfWeek = '" + strDayOfWeek + "')";

The SQL above returns nothing... I think the problem is GetDate() represents datetime and not just time only ....

Help...




Start Free Trial
 
Loading Advertisement...
 
[+][-]05.23.2008 at 10:39AM PDT, ID: 21634121

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 10:58AM PDT, ID: 21634261

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 10:59AM PDT, ID: 21634277

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 11:08AM PDT, ID: 21634335

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 11:09AM PDT, ID: 21634345

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 12:06PM PDT, ID: 21634892

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 12:22PM PDT, ID: 21635045

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.23.2008 at 01:58PM PDT, ID: 21635791

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 02:01PM PDT, ID: 21635815

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 09:15AM PDT, ID: 21643041

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Sign Up Now!
Solution Provided By: mark_wills
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.27.2008 at 12:30PM PDT, ID: 21654858

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 07:13PM PDT, ID: 21657254

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 05:45AM PDT, ID: 21659834

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906