Case statement to compare date and then count duration from only one date

Hi All;
I need to compare two dates and if date 1 > date 2 then consider date 2 and count its duration of appointments  from date 2
 case when CTE.scheduledstart  between [dbo].[DateTimeConvert] (new_dateofapplication) and 
         [dbo].[DateTimeConvert](ac.new_businessstartdate)
         then
        (CTE.scheduleddurationminutes)
 when  ( [dbo].[DateTimeConvert] (new_dateofapplication) >  [dbo].[DateTimeConvert](ac.new_businessstartdate))
        then
         [dbo].[DateTimeConvert](ac.new_businessstartdate)
        end as 'AFTERAPP',
Any help on this is much appreciated
I need to use case statement fro this
Thanks
Pradnya07

when you say list of Appointments from Appointments table calculate duration from this date [dbo].[DateTimeConvert]
do you mean find out duration from multiple record? or do you want
suration for each row? also what represents this date here? Is it new_dateofapplication?
can you show expected result for the data posted above?
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • SQL Query find month/year and then calculate difference from start date

    Hi All,
    Assume I have a table with a column Start_Date. I like to know how we can build a query to so we can find the end of the month date based on the start_ date and then calculate the difference
    For example lets say we have a date 12/06/2014 and now based on this we should get the end of the month date which is 30/06/2014. Now we can get the difference which is 18 days.
    Thanks

    Hi Jaggy99,
    According to your description, you need to get the date difference between a given date and the last day of that month, right?
    In this case, please try the query below.
    SELECT GETDATE() AS [CURRENTDAY], DATEADD(DAY,-1,DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)) AS [LASTDAY],
    DATEDIFF(DAY, GETDATE (), DATEADD(DAY,-1,DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0))) AS [DIFFERENCE]
    Regards,
    Charlie Liao
    TechNet Community Support

  • JSP: Date and Time Count down

    Hi All,
    Sorry if i come to the wrong place.
    I am thinking to write a code by using JSP to count down Date and Time. I have one field in my microsoft access format as Date/Time. I want to get the remain time by using the time in my microsoft access minus the current time in the machine and then count down the remain time.
    Could you please advise??
    Thanks for any advise you may give me,
    Kimsan

    Hi All,
    Sorry if i come to the wrong place.
    I am thinking to write a code by using JSP to count down Date and Time. I have one field in my microsoft access format as Date/Time. I want to get the remain time by using the time in my microsoft access minus the current time in the machine and then count down the remain time.
    Could you please advise??
    Thanks for any advise you may give me,
    Kimsan

  • Iphone 5 stuck on connect to itunes screen- if i try and get it out of recovery mode it trys to extract the data and then says the phones memory is full

    iphone 5 stuck on connect to itunes screen- if i try and get it out of recovery mode via itunes,  it trys to extract the data and then says the phones memory is full- cant seem to get it sorted, any ideas? I have an ipad mini if that helps?!

    Hey craigfromsheffield,
    I would suggest that you use the following information in order to help you resolve this issue:
    If you can't update or restore your iOS device
    http://support.apple.com/kb/HT1808
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Hi. My Ipad2 is being reseted each 1 minut of use and then I found this description "resetcounter(date and time).plist". Someone knows what this means and how to avoid this? Many, many thanks. iPad 2

    Hi. My Ipad2 is being reseted each 1 minute of use and then I found this description "resetcounter(date and time).plist". Someone knows what this means and how to avoid this? Many, many thanks.
    iPad 2

    Try resetting your device by holding down both the home and lock buttons for ~10 seconds or until the device restarts, ignoring the power slider. 

  • Hi, i had backed up my data and then when i restored my phone with the restore backup option, all the photos, music where there but no apps. Al my apps are disappeared. Can you please tell me where are my apps backed up?

    Hi, i had backed up my data and then when i restored my phone with the restore backup option, all the photos, music where there but no apps. Al my apps are disappeared. Can you please tell me where are my apps backed up?

    Apps (like other synced media like music) are not included in the backup that iTunes makes. Thus, restoring from backup if the apps are not in the iTunes library there are no apps to restore to the iPod.
    Redownload the apps into your iTunes library.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    And then restore from backup.
    Make sure that in iTunes>Preferences>Devices the box that say "Prevent iPods..." is checked otherwise when you connect the iPod to the computer the previous backup (with your app data) might be overwritten.

  • HT4085 Did all these things mentioned in this article, even did a system reset including data and other settings. iOS is up to date, still the iPad 2 display is not rotating.

    Did all these things mentioned in this article, even did a system reset including erase data and other settings. iOS is up to date, still the iPad 2 display is not rotating.
    This happened first a couple of weeks before, then I did a reset and it worked. Then after 2-3 days it happened again, I updated the iOS and it worked after that. Next time it happened, I tried all possible methods, including switching to software - rotation lock on/off. The hardware when turns to off/on, shows the correct icon on the screen of the lock and unlocked state. But the rotation is not happening.

    Just check again.
    If you see a lock icon in the upper right corner of the screen - then the screen orientation is locked.
    Try the side switch above the volume rocker first and see if that unlocks the screen. If that doesn't do it, double tap the home button and swipe to the right and look for the lock icon all the way to the left.
    If the screen is unlocked but still will not rotate, reset the iPad.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    If the iPad screen still will not rotate - turn it over and gently tap it on the back a couple of times - but gently tap it. Make sure that the screen is protected.

  • Is it possible to save an iPhone back up and access the files later if needed?  I have a string of text sms and iMessages that I would like to save and then delete them from my phone.  Is this possible?

    I have a string of text sms and iMessages that I would like to save and then delete them from my phone, but gain access to them later if I need them.  I prefer to have the string with the date/time stamp vs copying and pasting into a doc or text file.  Is this possible?

    Not unless you buy an app that accesses data from an iTunes backup.  Check in the app store.

  • How do I archive emails in mail and then delete them from my inbox?

    I need to archive a bunch of emails for a project, and I know that if I put them in a mailbox and then delete them from my inbox, they're gone. So, what's the most efficient way to save 100s of emails that will eventually need to be filed within a project file?

    // Sample code
    List resList = new Vector();
    MyObject obj = null;
    while(rs.next()) {
        obj.setXXX(rs.getXXX(i));  // Get from the resultset and set to the object
        resList.add(obj);
    // At the end of the loop, you have a Vector of objects holding data.What do you mean by returning Strings separately?

  • When I upload photos to iPhoto from my iPhone and then press delete from iPhone it does not delete them, how do I fix this?

    When I upload photos to iPhoto from my iPhone and then press delete from iPhone it does not delete them, how do I fix this?

    I am having the same problems as this person. I see that someone said there is no way to retrieve the pictures once it gets stuck in recovery mode.
    Then further along someone said that there are data retrieval methods except they have something to do with jail breaking a phone.
    My phone is already jail broken. It was kind of a gift from the company I work for- it was a fellow employees before. He jail broke it and then it was given to me. After I got it I activated the 4 and tried to back up everything. It didn't work and "Springboard" forced the phone into safety mode. So I could use it with the old dude's apps and my contacts. I made the mistake of using the phone for wedding dress shopping with a friend. I took tons of pictures.
    After this I found out the messages I was seeing meant it was jail broken. At&t said to force restore the phone - iTunes wouldn't recognize it in safety mode. I'm an idiot and didn't realize what this meant for my pictures. It didn't work (error 1611) - thankfully. Now it is stuck in recovery mode (iTunes icon and USB cable picture).
    Can I access that media in any way? It never suceeded restoring itself so is it still there? The phone is jail broken already so is there a method I can use?

  • Is there any way to set red to green and then delete all that in one time?

    Hi,experts
    In our delta data load requests include lots of red status record, in the usual way , we must fix the red status to green  and  delete it one by one.
    Is there any good way to set  status red to green and then delete all that in one time instead of one by one?

    hello,
    yes there is ways to delete the requests in one time.
    1)  Note the bad request number
    2)  Go to SE16
    3) Open table RSODSACTREQ. Filter the contents by that request number . There will be entries for that request . Delete that entries.
    OR
    4. Open table RSICCONT. There will be one entry for that request . Delete that entry
    OR
    5. Open Table RSMONICDP. Filter the contents by that request number . There will be 3-4 entries for that request depending on number of data packages in that request .Delete all those entries
    Hope this helps
    Kumkum

  • If I delete my songs from my "Downloads" folder, have them in my "Trash" and then delete them from my "Trash", will I still be able to play the songs on my iTunes or will they be deleted on my iTunes as well?

    I want to clear some space on my Mac since it is filling up and I don't have much room left on it. I want to delete all my songs from my "Downloads" folder and then delete them from my "Trash" to free up space however, I'm worried that if I do this then iTunes will not play any of the songs I deleted.
    Will I still be able to play my songs on iTunes even if they are not in my "Downloads" or "Trash" folders?
    Thank you.

    All tracks in iTunes (if you use default settings) should be in various artist and album folders in the main media folder in the iTunes folder. You can right click a track to reveal its location in Finder.  If there's a copy there then it doesn't really matter what you do with other copies.
    I have never downloaded from iTunes but I thought it placed files directly in the correct locations, or is this some other downloads folder to which you are referring?
    Normally if you download a file from another source and add it to iTunes by dragging it there, or using the Add To menu item, it places a copy of the file in iTunes.  You can discard the original, but if you're concerned you can check which copy iTunes is actually using as above.

  • After getting a new desktop I downloaded iTunes and authorized my new computer and then de-authorized my old one,  When I try to update my 5S it says my phone is not authorized and list my wifes email address as the account holder and not mine.  How

    After getting a new desktop I downloaded iTunes and authorized my new computer and then de-authorized my old one,  When I try to update my 5S it says my phone is not authorized and list my wifes email address as the account holder and not mine.  How do I correct this. I am using Windows 8.1 .  My wife has never had an iTuunes account

    Hello Lakesidetom,
    It sounds as though you are experiencing an issue with an Apple ID and authorizations. Based on your post, it sounds like you are familiar with the authorizing and deauthorizing process. The Apple ID in question (your wife's email) may be originating from the iPhone you are attempting to update. Is it possible that your wife created an Apple ID or iCloud account which is signed in on that iPhone? Below, I have included links to some resources that may help you determine if your wife has created an Apple ID:
    How to find your Apple ID - Apple Support
    Use these steps if you forgot your Apple ID or aren't sure that you have one.
    Apple - My Apple ID
    If you can't remember your Apple ID, just provide us with some information and we'll find it for you. Then we'll help you reset your password.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    Bobby_D

  • ITunes Match on Windows 7 64 iTunes 10.5.2 64 -  - please sign in again itunes match has encountered an error. Please choose sign out and then sign in from the itunes store menu and try again.

    Windows 7 64 itunes 10.5.2 64 - I receive the following error message when opening iTunes - please sign in again itunes match has encountered an error. Please choose sign out and then sign in from the itunes store menu and try again.
    When I try to sign out iTunes freezes and I need to shut down windows entirely to get it to open again.
    Has anybody been able to resolve this issue?

    After many annoying sign-in-out-iTunes-match-activation problems I found an easy solution for me. When the iTunes Cloud symbol is broken (and I should sign in again) I just deactivate my notebooks (Windows 7) Wifi (with Fn+F5 for my Thinkpad).Then I call up the Itunes store and iTunes tells my that there is no connection to the internet (most probaply this step is not necessesary). After manual re-activation of my Wifi iTunes seems to re-establish the connection and the Cloud symbol signalizes that iTunes match does work, again.
    Hope, this helps.

Maybe you are looking for

  • Print report does not work in built mode (LV7.1+XP)

    Good morning, I've read some threads about the topic in this Q, but no solution. So my hope is that NI has resolved the problem. Here it goes: In normal edit mode I can use the Print Report.vi (using the default win printer) to print out some data. T

  • Verizon Internet Security Suite - says subscription ended but account is active

    After several attempts with Verizon reps to get our online backup increased from 50gb to 150gb, Verizon finally figured it out and now we have more backup memory.  However, in the process of doing that, Verizon went and terminated our internet securi

  • How to create a standby database?

    I am running Oracle 8.1.5 on Sun Solaris. How to create a standby database? Can somebody tell me the step-by-step procedure?

  • JTree custom implementation

    Hi All, I have application, which eats all the memory, when I load big structure in JTree. So I have modified following function DefaultTreeMutableNode { public void insert(MutableTreeNode newChild, int childIndex) {           children = new Vector()

  • Adding text to a string

    Hi I am new to Numbers (I am using 09 on OS X 10.6.8)  - I need to add a couple of characters to the end of a text string in one cell, if the condition in another cell is true. A1 contains a persons name  A2 can contain the formula I am seeking A3 wi