Set flag in DB if the date is 5 days in the past

I've written some code using SQL that checks today's date and compares is to an entry in the database, which I have called EndDate.  If the EndDate is within 60 days an email will be generated. If data in the database is 60 days or more in the future
it returns the data from the query.
Here is the code:
Use LOGONs
Select DateAdd(d, DateDiff(d, 0, EndDate), 0) As KeyedDate, Service, Manufactureer, [AccountNumber], GETDATE() as TodayTime
From ServiceExpiryMAtrix
where DATEDIFF(d, GETDATE(), EndDate) < 60
I have created another column in the database called expired, that I'd like to update with either yes or no if the Enddate field is over 5 days old.  The idea behind this is to control whether emails are continued to be sent once the EndDate date has
passed.
I have seen that this should be done in the select query but being new to SQL I thought I'd ask the question...
James
Alter De Ruine

This way you don't have to update any column every day.
Each time you select your table it'll give you the correct value.
If you want to stick with updating just do this:
UPDATE LOGONs SET Expired = case when datediff(day,getdate(),[EndDate])>(5) then 'yes' else 'no'  end
WHERE isnull(Expired,'') <> case when datediff(day,getdate(),[EndDate])>(5) then 'yes' else 'no'  end
or
UPDATE LOGONs SET Expired = case when datediff(day,getdate(),[EndDate])>(5) then 'yes' else 'no'  end
WHERE isnull(Expired,'no') = 'no'
Then you can set the default value for your column to 'no'  and only update to 'yes'....
"If there's nothing wrong with me, maybe there's something wrong with the universe!"

Similar Messages

  • Mail setting to download mail from the past months

    Hi,
    I just want to know how I can set the mail on Mac book air to store or download emails up to last months or 2 months or 2 weeks...ect.
    Like my company email and gmail, after I set up the server, it will try to download all the emails.
    Thanks

    Went to Preferences, clicked on the account in the left side menu, clicked the minus sign. Before deleting the account the computer toggled me to another window for managing Internet Accounts. I clicked the minus sign again for that same email account and the account no longer appears in my email account list.
    Based on other posts about deleting an email account, I was expecting to see this prompt: "The account's setup information, mailboxes, messages, notes and to do's will be deleted permanently from your computer"
    However, that prompt didn't appear. Instead I was directed to the Internet Accounts preferences pane as described above. While in Mail, if I go to preferences, the deleted account is not there and I do not have the option to send emails via the deleted account. The only functionality still enabled is the receipt of new messages.

  • I can't get rid of an old email that I set up apps on in the past. I don't have a password. I can't update anything.

    I have an old email that I can't get rid of. Every time I try to install app updates it asks for my password (which I don't remember, and I don't have that email to receive anything). I have gone to settings in icloud and I only have my updated info. Help! I can't even play some of the games without doing an update.

    Hi THIVELY,
    Since applications from the app store are linked to the Apple ID - in this case your old email - used to purchase or obtain them, you will need to have the password to that Apple ID in order to update those apps. This article will tell  you how to reset that password so you can continue to use that Apple ID -
    If you forgot your Apple ID password
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • How to extend the validity of a validation set to the past?

    By t.code GS01 I've created a a set for Valitation rules (OB28).
    Then, I've verified that the set isn't valid for the past.
    How to extend the validity of the set to the past?
    Thanks
    Gandalf

    Hi,
    I think we can not maintain validity dates for Validation.
    Just go to T. Code OB28 set your Co Code, Call Point and set activation Level as 1 to activate your validation.
    Regards,
    JA

  • Same set of Records not in the same Data package of the extractor

    Hi All,
    I have got one senario. While extracting the records from the ECC based on some condition I want to add some more records in to ECC. To be more clear based on some condition I want to add addiional lines of data by gving APPEND C_T_DATA.
    For eg.
    I have  a set of records with same company code, same contract same delivery leg and different pricing leg.
    If delivery leg and pricing leg is 1 then I want to add one line of record.
    There will be several records with the same company code contract delivery leg and pricing leg. In the extraction logic I will extract with the following command i_t_data [] = c_t_data [], then sort with company code, contract delivery and pricing leg. then Delete duplicate with adjustcent..command...to get one record, based on this record with some condition I will populate a new line of record what my business neeeds.
    My concern is
    if the same set of records over shoot the datapackage size how to handle this. Is there any option.
    My data package size is 50,000. Suppose I get a same set of records ie same company code, contract delivery leg and pricing leg as 49999 th record. Suppose there are 10 records with the same characteristics the extraction will hapen in 2 data packages then delete dplicate and the above logic will get wrong. How I can handle this secnaio. Whether Delta enabled function module help me to tackle this. I want to do it only in Extraction. as Data source enhancement.
    Anil.
    Edited by: Anil on Aug 29, 2010 5:56 AM

    Hi,
    You will have to do the enhancement of the data source.
    Please follow the below link.
    You can write your logic to add the additional records in the case statement for your data source.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c035c402-3d1a-2d10-4380-af8f26b5026f?quicklink=index&overridelayout=true
    Hope this will solve your issue.

  • How to set a variable value on the BPC Data Manager

    Hello BPC Experts,
    I'm creating a BPC10 NW version demo environment for our prospect customer.
    I made a data manager to import  BW data into BPC model from BW cube.
    I need to import just one month data into BPC from the BW cube that has more than one month data.
    When I run the data package manually, I can select a member of the time dimension prompt and I can import specific month data I want.
    But, in a case where the program (data manager) runs by JOB monthly,
    I can't select a member of the time dimension prompt manually.
    So I want to know how to set a  variable value to the time dimension prompt from a system date etc. automatically.
    Are there any way to set a variable value to the time dimension prompt on the data manager automatically from a system date?
    Or, do you have any other solution to import just one month data into BPC from the BW cube that has more than one month data  by the data manager running on JOB ?
    (without selecting a member of the time dimension prompt of the data package manually)
    Thanks in advance,
    Keisuke

    Hi Gersh
    Sorry for my late reply and thanks for your helpful information.
    I tried the second way of your information and I could configure it.  
    And I 'll try first way of your information.
    Regards,
    Keisuke

  • TS3297 when I press the iTunes button on my ipod touch I get the message 'cannot connect to iTunes store' .  My wifi is working fine, I can connect to safari & you tube, no parental setting in place, and time and date are correct. Can anyone help please?

    When I press the iTunes button on my ipod touch I get the message 'cannot connect to iTunes store' .  My wifi is working fine, I can connect to safari & you tube, no parental setting in place, and time and date are correct. Can anyone help please? I have restored my ipod to factory settings and rest it.

    I also tried moving the date forward by a year and then moving it back to normal and it still doesn't work.  i can't find an automatic update of time zones on my itouch to turn this off.

  • Dynamic Calc processor cannot lock more than [100] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).

    Hi,
    Our Environment is Essbase 11.1.2.2 and working on Essbase EAS and Shared Services components.One of our user tried to run the Cal Script of one Application and faced this error.
    Dynamic Calc processor cannot lock more than [100] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).
    I have done some Google and found that we need to add something in Essbase.cfg file like below.
    1012704 Dynamic Calc processor cannot lock more than number ESM blocks during the calculation, please increase CalcLockBlock setting and then retry (a small data cache setting could also cause this problem, please check the data cache size setting).
    Possible Problems
    Analytic Services could not lock enough blocks to perform the calculation.
    Possible Solutions
    Increase the number of blocks that Analytic Services can allocate for a calculation:
    Set the maximum number of blocks that Analytic Services can allocate to at least 500. 
    If you do not have an $ARBORPATH/bin/essbase.cfg file on the server computer, create one using a text editor.
    In the essbase.cfg file on the server computer, set CALCLOCKBLOCKHIGH to 500.
    Stop and restart Analytic Server.
    Add the SET LOCKBLOCK HIGH command to the beginning of the calculation script.
    Set the data cache large enough to hold all the blocks specified in the CALCLOCKBLOCKHIGH setting. 
    Determine the block size.
    Set the data catche size.
    Actually in our Server Config file(essbase.cfg) we dont have below data  added.
    CalcLockBlockHigh 2000
    CalcLockBlockDefault 200
    CalcLockBlocklow 50
    So my doubt is if we edit the Essbase.cfg file and add the above settings and restart the services will it work?  and if so why should we change the Server config file if the problem is with one application Cal Script. Please guide me how to proceed.
    Regards,
    Naveen

    Your calculation needs to hold more blocks in memory than your current set up allows.
    From the docs (quoting so I don't have to write it, not to be a smarta***:
    CALCLOCKBLOCK specifies the number of blocks that can be fixed at each level of the SET LOCKBLOCK HIGH | DEFAULT | LOW calculation script command.
    When a block is calculated, Essbase fixes (gets addressability to) the block along with the blocks containing its children. Essbase calculates the block and then releases it along with the blocks containing its children. By default, Essbase allows up to 100 blocks to be fixed concurrently when calculating a block. This is sufficient for most database calculations. However, you may want to set a number higher than 100 if you are consolidating very large numbers of children in a formula calculation. This ensures that Essbase can fix all the required blocks when calculating a data block and that performance will not be impaired.
    Example
    If the essbase.cfg file contains the following settings:
    CALCLOCKBLOCKHIGH 500  CALCLOCKBLOCKDEFAULT 200  CALCLOCKBLOCKLOW 50 
    then you can use the following SET LOCKBLOCK setting commands in a calculation script:
    SET LOCKBLOCK HIGH; 
    means that Essbase can fix up to 500 data blocks when calculating one block.
    Support doc is saying to change your config file so those settings can be made available for any calc script to use.
    On a side note, if this was working previously and now isn't then it is worth investigating if this is simply due to standard growth or a recent change that has made an unexpected significant impact.

  • I have an iphone 4s that i got last week and i set it up just using the phone. today my dad restored it as my mothers iphone so i lost all of my data. I tried to restore it as my original phone i had but i exited out of itunes and now my phone wont showup

    I have an iphone 4s that i got last week and i set it up just using the phone. today my dad restored it as my mothers iphone so i lost all of my data. I tried to restore it as my original phone i had but i exited out of itunes and now my phone wont showup in itunes or on my computer

    Did you fail to import them to your computer before restoring?
    Not good.
    They are likely gone.
    You can try restoring from backup.

  • Trying to do a password update but it asks me for a four digit pass code. Does anyone know if that would have been a significant date or set of letters or numbers I was prompt for in the past when I first bought my phone?  Thanks.

    Trying to do a password update but it asks me for a four digit pass code. Does anyone know if that would have been a significant date or set of letters or numbers I was prompt for in the past when I first bought my phone?  Thanks.

    It rather depends on where you are seeing the demand for a passcode. If, as I assumed, you are trying to change the password at http://appleid/apple.com then that will ask for a passcode if 2-step verification has been set up. On the other hand, if, as Csound1 has assumed, you have changed the password on that website and are trying to enter it in your phone (for which you need to sign out completely before you can do this) and are being asked for a passcode that can only be one you set yourself (unless of course the phone is second-hand in which case that would open a whole new can of worms).

  • Wht is  ALV setting/flag to deletes the preceeding zeros in doc #s,?

    Hi Experts,
    am displaying doc #s in my_alv, so the zeros r coming as prefix........i wanna to truncate zeros......so, can use FM conversion exit..........but, pls. let me know that,
    Is there any  ALV functionality in SAP, which deletes the preceeding zeros in Sales doc, delivery doc #s?
    (Wht is  ALV setting/flag to deletes the preceeding zeros in doc #s,?)
    thanq
    Edited by: Srinivas on Feb 8, 2008 4:40 PM

    While defining field catalougue , define it as
      fieldcat_ln-no_zero  = 'X'.
    preceeding zeros of documents nos will not be displayed in ALV list.
    anya

  • How to set field to blank if the data is # or unassigned

    hi experts,
    how to set field to blank if the data is # or unassigned?
    thx

    Hi
    add the following macro to your workbook (template workbook):
    Sub SAPBexonrefresh(qstring As String, resultArea As Range)
        For Each c In resultArea
            If LCase(c.Value) = "not assigned" Then c.Value = ""
           Next
    End Sub

  • Collecting data to be compared in set ranges that would trigger the next step

    We are collecting data from a pressure transducer that needs to be read by LabVIEW. The data needs to be compared to a set range (min/max) that would determine the following 2 steps: if within the range, keep collecting data OR if outside of the range, another action would occur. The following action is the control of the pump, so either the pump continues at set flow or LabVIEW tells the pump to increase/decrease flowrate. We are having trouble trying to analyze the data so that is can be compared so we know whether it is within the set range. Is it possible that LabVIEW can continously acquire data from the pressure transducer and also analyze it at the same time? Also, what is the best option/way to compare the data within the set range; an event structure, a comparator, so that the results of the comparsion can relay a signal to the pump?
    Helpful links to tutorial sections would be very useful, if anything.
    Thank You!

    Look at the in range and coerce function on the comparison palette.  It outputs a boolean which would drive a case structure.  If the action for out of range high and out of range low need to be different, you could do a couple of comparisons to see if the value exceeds the max or is below the minimum and act according in a case structure inside of the True case of the first case structure.

  • I changed my data plan yesterday. I should have set it to change at the new month which is tomorrow. can i fix this?

    I changed my data plan yesterday. I should have set it to change at the new month which is tomorrow. can i fix this?

    I don't know if they'll be able to change it or not, but it's worth calling Customer Service ASAP (since you indicate your billing cycle starts tomorrow, so that would be midnight tonight) and asking.
    Customer Service
    Dial *611 from a cell phone
    (800) 922-0204
    Monday - Sunday 6 am - 11 pm

  • I am running Logic Pro 9.1.7, and I use a Roland RD700GX keyboard to input midi data into Logic.  How do I set up Logic to record the Roland's own internal Grand Piano sounds into Logic, while retaining the ability to make midi edits? By Eggie

    I am running Logic Pro 9.1.7 on a mid-2011 Intel iMac running OS10.7.4. I use a Roland RD700GX as my midi input keyboard.  How can I set up Logic to record The RD700GX's own internal Grand Piano sounds, while retaining the ability to take advantage of Logic 9's midi editing capabilities. I am a relative newcomer to Logic, and I haven't been able to find an answer in The Logic 9 User Manual. A step by step procedure would be much appreciated. Thank you.
    Eggie0379

    Create a new External Midi Track, set the MIDI port to the one being connected to teh RD700. Now,create a new Software Instrument track. Select the external instrument plug-in. Set the MIDI destination and the audio input inside the Plug-in. Now, you can record the MIDI notes and hear the sound of the RD700. Once you've editied, you can bounce the track.
    Best,
    DaCaptain

Maybe you are looking for

  • Changing country - problem with cards

    Just moved to Australia, cancelled my UK cards and now can't buy anything on iTunes because I need to have a UK card because my iTunes is registered for the UK region. So change region? Can't change region until I've entered a legitimate UK card, whi

  • HT2311 how to authorise a new iMac for iTunes

    Hi All, complete newbie to all things Apple. Just got a new iMac struggling a little with many things any advice would be very welcome ......before i go off the idea that a Mac was a good decision. Current Probs: 1. Cant find out how to authorise the

  • Lightroom Caption Export

    Hello Lightroom community! I am using Lightroom 3 and I am using OS X 10.9.4. With this version of OS X and every version I've used before, whenever I export JPEGs from Lightroom and subsequently upload to Facebook, the caption automatically provided

  • Is the 2010 answer about firesheep encryption boxes still valid? I'm using an online library catalog; no sign-in needed. I didn't have

    I work at an extension campus for a community college and have never had this problem before when searching the college's library catalog. Every time I click to open a book record or see the next page in a list of books, this Security Warning box app

  • Battery wont charge above 82%

    I followed the calibration guide in the manual and let my MBP sleep for a over five hours before plugging the power source back in. I let it charge overnight and when i turned it on the level was only 93%. As i used it, the battery level dropped and