Solved

datetime filtering

Posted on 2008-06-24
6
261 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
  • 3
  • 3
6 Comments
 
LVL 142

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 142

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 142

Expert Comment

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

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now