Convert string to datetime and then use in a where clause

I am trying to pull in warranty expiry dates that have been entered as strings and then perform a calculation as to which ones are expired, about to expire within
90 days or will expire in more than 90 days. I have got the query to a point where I have converted it to a datetime field (though I'm sure I used the right value to just give me the date, its giving me date and time) and have it printing out the machine name
and the warranty for that machine.
SELECT
  machNameTab.machName
  ,convert(date,auditRsltManualFieldValues.fieldValue,103) AS warranty
FROM
  machNameTab
  INNER JOIN auditRsltManualFieldValues
    ON machNameTab.agentGuid = auditRsltManualFieldValues.agentGuid
WHERE
  machNameTab.groupName = N'root.company'
  AND auditRsltManualFieldValues.fieldNameFK = 958472722796011
What I need to do next is change this so instead of just spitting out all the dates as 'Warranty', I want it to give me the fields 'Expired', 'Expiring' (expiry date is within 90 days of the current date) and 90Days (expiry date is over 90 days from the current
date)

SELECT
machNameTab.machName
,convert(date,auditRsltManualFieldValues.fieldValue,103) AS warranty,
select
case
when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )<90 then 'Expiring'
when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )<0 then 'Expired'
when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )>=90 then '90Days'
end as status
FROM
machNameTab
INNER JOIN auditRsltManualFieldValues
ON machNameTab.agentGuid = auditRsltManualFieldValues.agentGuid
WHERE
machNameTab.groupName = N'root.company'
AND auditRsltManualFieldValues.fieldNameFK = 958472722796011
I added a case to your select. The case will output the strings you wanted based on the date.

Similar Messages

  • How to convert string to date and check date difference in filter clause | error in filter clause

    Hi All,
    I have a requirement where i want to stop replicat if particular record is encountered on target.
    if PARAMETER_CODE="APPLDATE" and difference between parameter_value is 1 then replicat should stop.
    the code i am using is,
    map schema.src_tablename , target schema.trg_tablename, &
    WHERE(PARAMETER_CODE="APPLDATE"), &
    filter (on updates, (@to_date(before.PARAMETER_VALUE,'dd/mm/yyyy hh24:mi:ss')) - (@to_date(PARAMETER_VALUE,'dd/mm/yyyy hh24:mi:ss')) =1), &
    EVENTACTIONS(STOP);
    Replicat process abends with error in filter clause.
    Concern here is the parameter_value column is in varchar2 and not in date. (if its date than filter (on updates, @datediff ("DD",before.PARAMETER_VALUE, PARAMETER_VALUE) =1)  is working correctly). I need to stop replicat when date(in varchar2 format) gets incremented by 1.
    Please do help in solving the issue.
    Thanks,
    TrushB.

    Dear all,
    Please do update... how to covert a varchar2 to date in GG.

  • Converting from spreadshet string to array and then back to spreadsheet string

    My questions is; why is the Spreadsheet string to array function creating more data than the original string had when you change the array back into a spreadsheet string. Im trying to analyze a comma delimited file using array functions since my column and row size is constant, but my data varies. Thus my reason for not using string parsing functions which would get more involved and difficult. So, however, after i convert to a 2D array of data from the comma delimited file I read from, and then I convert back to string using the Array to Spreadsheet String, I get added columns to the file, which prevents another program from receiving these files. Also, the data which I am reading is not all contiguous, it has gaps in some places for empty data. Looking at the file compared to the original after it has gone from string to array and then back to string again, looks almost identical except for the file size which got larger by 400 bytes and where the original file has empty spaces, the new file has a lot of commas added. Any idea?
    Charles

    The result you get is normal when the spreadsheet string contains rows of uneven length. Since the array rows have the same number of elements, nil values are added during the coonversion. And of course, the back to string conversion keep those added values in the string, with the associated commas.
    example : 3 x 3 array
    1,2,3
    4
    5,6,7
    is converted into
    1 2 3
    4 0 0
    5 6 7
    then back to
    1,2,3
    4,0,0
    5,6,7
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Is there a way to create an object using Trapcode Form and then use that object as a particle in Trapcode Particular?

    I made some objects in Cinema 4D and I tried to import them into After Effects CC 2014.  I get an error saying 'Cannot find Adobe Premiere Pro Dynamic Link'.  So I tried it in AE CC and that worked.  However, I want to create a form object and then use that as a particle for Trapcode Particular.  Is this even possible?
    Thank you for any help!

    There are also size limitations or rather suggestions for particle size. If I were creating an animated 3D shape using Form or C4D and wanted to use it as a particle I would keep the size of the particle about 1/6 to 1/8 of the comp size. You would create a new comp for your particle, animate it, then nest the particle comp in your main comp, turn off visibility, and then use it as a particle in Particular.

  • I want to be able to use airplay to stream audio to another iOS device, and then use that audio stream to be used when recording video instead of the built in microphone / microphone input. Is this possible?

    I want to be able to use airplay to stream audio to another iOS device, and then use that audio stream to be used when recording video instead of the built in microphone / microphone input. Is this possible?

    A third-party app probably cannot obtain a stream from another app. To the best of my knowledge, such a capability is not provided in the software development kit, apps being "sandboxed" from each other and so allowed to communicate only in very specific and limited ways.
    I'm not completely sure what you mean by "limitations on video capture". An iPhone, to the best of my knowledge, can natively record video only through it's built-in camera, and audio while doing video recording only through the built-in microphone or mic/headphone jack. There might be a video recording app that would allow audio input from an external device connected to the dock connector, but I'm not sure.
    Regards.

  • Can I put a SQL query into a bind variable and then use it to output report

    Hi,
    Can I put a SQL query into a bind variable and then use it to output report?
    I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
    select * from (:P1_TEXT);
    Do you think it is possible to do that? Any known limitations for APEX in this area?
    Thanks a lot,
    Angela

    You can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
    You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
    Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
    Tyler

  • How can I import a non-BC site into BC, using Dreamweaver CC, and then use it as one of my free sites?

    I am trying to import one of my non-BC sites into BC, using Dreamweaver CC, and then use it as one of my free WebBasics sites.
    When I try to create a new BC site in Dreamweaver CC, it creates a BC template site, and I have unsuccessfully tried to update the files on BC - it won't let me connect.
    If I import the site from my portal, I don't get the option of a free site - when I try to upgrade, I get the credit card form asking for payment.
    I feel like I'm running around in circles with one foot nailed to the floor.
    Any tips?

    Thank you for your quick reply and for clearing up my confusion.  I'm exporting the first section now.  I choose the smallest size, 3x4 but I'd prefer to go higher as this DVD was originally a VHS home movie.  I'm wondering if after three conversions (VHS,->DVD->MPEG) the resolution will be so poor as to not support a larger size frame?  If it can, what size should I select when I export? 

  • I bought my iPhone 4s in the Uk and then brought to Cyprus where I live. I used Siri to call my husband 2 days ago without problem but now when I try to use Siri it won't call any local Cypriot number but will call my Uk contacts. Help please

    I bought my iPhone 4s in the Uk and then brought to Cyprus where I live. I used Siri to call my husband 2 days ago without problem but now when I try to use Siri it won't call any local Cypriot number but will call my Uk contacts. I can call the same numbers manually so it's not my network. Any help would be appreciated.

    This sounds like an international issue? Although I can not see why? I brought my phone in Australia and operating it in Indonesia, I have the same issues.... Otherwise Siri works fine, even texting (SMS) to local numbers siri works well, but dialing local number it just wont work...! I will try using my Australian SIM card and see if that is the reason.. I tried changing the number in the contacts and took out the international prefix, I turned the international assist on and off still nothing.. How frustrating. I called apple, the technican had know idea and we to his supervisor, had to wait fro 40 miuntes and then I hung up..
    PLEASE HELP..!

  • What are the steps to make it seamless for a customer to use the install program and then use the installed program?

    I wrote an install program (.exe) that is downloaded from a website.  When run, it 1) leads a customer to browse to a directory, and 2) copies files (.exe, .dll, etc.) from a website to that directory.  When I run, the installed program works.
    What are the steps to make it seamless for a customer to use the install program and then use the installed program? 
    bhs67

    This site https://msdn.microsoft.com/en-us/library/vstudio/2kt85ked%28v=vs.110%29.aspx provides a basic description of the Visual Studio Windows Installer. 
    Near the bottom of the page is "You can unlock all the features of InstallShield by paying to upgrade to the full version of InstallShield."  Where do I find info that describes the differences between the "free" and the "full"
    versions?
    bhs67
    Hello,
    The default feature does support the task for your requirement, so there is no need to pay for the other features unless you want to use some feature which is not free.
    In addition, as this thread
    InstallShield LE not available with VS 2012 RTM? shared, even through there is a link to InstallShield LE in the New Project dialog under Deployment solutions, but it belongs to third-party that I would recommend you consider posting this issue
    at the following forum to get supports about InstallShield.
    http://community.flexerasoftware.com/forumdisplay.php?133-InstallShield
    Regards.
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Is it possible to reinstall Mac OS X Lion on MacBook and then use Time Machine to restore to the previous backup I made before reinstalling Mac OS X Lion?

    Is it possible to reinstall Mac OS X Lion on MacBook and then use Time Machine to restore to the previous backup I made before reinstalling Mac OS X Lion?

    My MacBook was not normally booting up. It would turn on, make the Apple startup noise, and the bottom loading bar would progress just a little bit, then my MacBook would shut down. I tried rebooting it many times and the same thing would happen, it would just shut down. Then, I read that I can reset the PRAM (by holding Option+Command+P+R after the Apple startup noise comes). That worked, but now I get a screen that asks me to choose one of the 4 options (see:  http://images.macworld.com/images/article/2012/07/lionrecoveryutilities-289404.j pg). I choose Restore From Time Machine Backup, but it progresses to 17.6% and gets stuck there forever. I tried doing it again, and it got stuck at 17.6% again. That is why I am asking if I should just reinstall Lion, then restore a previous backup on the fresh new Lion?

  • Received adobe photoshop elements 12/adobe premiere elements 12 when I purchased a MacBook Pro.   The macBook Pro does not have a DVD player it is sold separately.     To install the program can I download a free trial version and then use the serial numb

    Received adobe photoshop elements 12/adobe premiere elements 12 when I purchased a MacBook Pro.   The macBook Pro does not have a DVD player it is sold separately.     To install the program can I download a free trial version and then use the serial numbers from the set I received?

    yes, that's exactly what you should do,
    Downloads available:
    Suites and Programs:  CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  12 | 11, 10 | 9,8,7
    Lightroom:  5 | 4 | 3
    Captivate:  7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • Can I attach a link to one image and then use that linked image multiple times in my site?

    Hi,
    Is it possible to attach a link to an image and then use that image (with link attached) multiple times in my site.
    Thanks,
    Ally

    Use 'Find and Replace'>under the 'Edit' menu.
    Select from 'Find in'- Folder and browse to the folder your website files are kept in to select it.
    Search: Source Code
    In the Find box (but obviously use YOUR image code):
    <img src="images/imageName.jpg" width="200" height="200" alt="" />
    In the Replace box: (use YOUR link and image code)
    <a href="yourLink.html"><img src="images/imageName.jpg" width="200" height="200" alt="" /></a>
    Then select 'Replace All'

  • I installed Firefox sync and then used iphone app called FireFox Home and I can syncronize history, tabs and bookmarks. But I am NOT able to syncronize passwords from Firefox in my Macbook to FireFox Home on iPhone !

    I installed Firefox sync and then used iphone app called FireFox Home and I can syncronize history, tabs and bookmarks. But I am NOT able to syncronize passwords from Firefox in my Macbook to FireFox Home on iPhone so I am very terrible to input my IDs and Passwords with my hands on FireFox Home when I log into Facebook, Twitter etc... Is it issue or something like that? If you have some solutions to make it clear, can you tell me how to syncronize memorized IDs and Passwords for the webs. Thank you.

    You can look in Tools > Options > Sync
    Menu differences: [http://kb.mozillazine.org/Menu_differences Windows: Tools > Options - Mac: Firefox > Preferences - Linux: Edit > Preferences]
    See also:
    * [[What is Firefox Sync]]
    * [[How to sync Firefox settings between computers]]
    * [[How to sync Firefox between my desktop and mobile]]

  • How can I apply a timestretch to different null objects and then use them to parent layers?

    I am using several hundred stills which are held on screen for different lengths of time. Is there a way to create null objects with various timestretch values and then use them to parent my stills?
    I'm trying to find an equivalent to the 'paste attributes' function in Final Cut Pro.
    Thanks in advance
    A

    If you have movement on the stills you can set up expressions based on in and out points. That's what I do. I then drop all my stills in order into a comp then set the out point for all stills for the longest duration. I then set group colors for layers that I want to make different lengths, do a group select and then adjust the out points for those layers. When I'm done I sequence the layers using the keyframe assistant.
    The other way I work is to use an audio track with markers for timing. I have an expression that reads the markers and sets opacity for the layers based on pairs of markers. The motion is also controlled by expressions. That's an even faster way to set up an animated slide show.
    The last way I work is just to set in an out points for all layers, sequence the layers, use expressions to do the motion and then use time remapping on a pre-comp to adjust the timing of the slide show. All methods are quick and easy.
    Here's a fly in bounce and then drop out fxx preset that will give you an idea of how expressions based on in and out point work for slide shows. You just drag the layer to it's resting position, apply the animatiokn preset and the layer flys in, bounces, and then drops out the bottom of the comp. Works in 2D and 3D space.

  • HT201371 does touching the home button wakes up the iPhone 5s or do we physically have to Click on Home Button or Sleep/Wake button and then use touch id?

    does touching the home button wakes up the iphone 5S or do we physically have to Click on Home Button or Sleep/Wake button and then use touch id?
    What I am trying to say is that each time I have to click on the home button to wake up the iphone 5s and then it scans my print and logs me in the phone however I was hoping that by just putting the finger on the button will do the whole thing of waking up + unlocking the phone,
    Can anyone please let me know if I am wrong or if I am right? since I just bought iphone 5s and I am not sure if the sensor is working or not the way it should be.

    It sounds like it is working the way it should be. You do have to click one of the two buttons. The closest thing to doing it as a single operation is to click the Home button but don't remove your finger from the button (i.e., leave your finger lightly on the button immediately after clicking it).

Maybe you are looking for