?
Solved

datetime filtering

Posted on 2008-06-24
6
Medium Priority
?
267 Views
Last Modified: 2013-12-16
Date and Time is stored in the DB field as follows:

25/06/2008 11:28:49

...the relevant part of the sql statement attached below :

(DateTimeCallBack < '" + serverTime.AddDays(1).ToString("ddMMyyyy HH:mm:ss") + "') ORDER BY DateTimeCallBack ASC

what am I doing wrong please?

... I wanting to filter historic and upto today (date and time) ... so for example it is 11:53 GMT when I wrote this note -- so if I were to search the db -- I would want only to have historic (date) and upto 11:53 GMT todays records to be returned etc.

InitialiseLeadCall("SELECT TOP 1 T1.[MasterAccount_ID], LTRIM(RTRIM(T1.[DisplayNameApp1])), LTRIM(RTRIM(T1.[DisplayNameApp2])), T2.[LeadSourceProviderProductName], LTRIM(RTRIM(T1.[TelWorkApp1])), LTRIM(RTRIM(T1.[TelHomeApp1])), LTRIM(RTRIM(T1.[TelMobileApp1])), LTRIM(RTRIM(T1.[TelWorkApp2])), LTRIM(RTRIM(T1.[TelHomeApp2])), LTRIM(RTRIM(T1.[TelMobileApp2])), T1.[LeadSourceProviderProducts_ID], T1.[ApplicationTypeJointSingle], T1.[AssociatedSpooler_ID] FROM [MasterAccounts] T1 LEFT JOIN [LeadSourceProviderProducts] T2 ON T1.[LeadSourceProviderProducts_ID] = T2.[LeadSourceProviderProducts_ID] WHERE [AssignedStaffMember]=" + (String)Session["fortuneAgent_ID"].ToString() + " AND [DIPStatus]=0 AND [ActiveMemberStatus]=1 AND (DateTimeCallBack < '" + serverTime.AddDays(1).ToString("ddMMyyyy HH:mm:ss") + "') ORDER BY DateTimeCallBack ASC");

Open in new window

0
Comment
Question by:amillyard
[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
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21854290
is the data type DATETIME in that table?
a=yes:
 DateTimeCallBack < getdate() ORDER BY DateTimeCallBack ASC



0
 

Author Comment

by:amillyard
ID: 21854683
yes.  but I use the following for the current datetime as the sql server is in a different timezone to user and web-site as follows:

DateTime serverTime = DateTime.Now.AddHours((int)Session["fortuneAgentGMT_offset"]);

so, with that in mind do I update your supplied scripting as follows:

DateTimeCallBack < serverTime ORDER BY DateTimeCallBack ASC


0
 

Author Comment

by:amillyard
ID: 21854804
do I not need the :

serverTime.AddDays(1).ToString("ddMMyyyy HH:mm:ss")
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 21854955
getdate() is the time on the server.
0
 

Author Comment

by:amillyard
ID: 21912063
getdate()   -- this will filter the current date & time, does it filter 'seconds' as well ?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21913515
yes.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

771 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