Solved

datetime filtering

Posted on 2008-06-24
6
265 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

691 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