I hate to reinvent the wheel - Date/time differences

Does anyone have a concise SQL algorithm to find the difference between
2 dates and times where the dates are stored in a date field and the times are stored as a varchar in the format HH:MM:SS (24 hr clock).

Hi,
I am using a stored procedure which give calculates the no of days between two dates. Try using/modifying it and see if it is of any help
The Procedure................
DECLARE
     vdDateFrom DATE;
     vnDayFrom NUMBER := 0;
     vnMonthFrom NUMBER := 0;
     vnYearFrom NUMBER := 0;
     vdDateTo DATE;
     vnDayTo NUMBER := 0;
     vnMonthTo NUMBER := 0;
     vnYearTo NUMBER := 0;
     vnYearsDiff NUMBER := 0;
     vnMonthsDiff NUMBER := 0;
     vnDaysDiff NUMBER := 0;
     E_STOP EXCEPTION;
BEGIN
     vdDateFrom := '01/11/2001';
     dbms_output.put_line('Date From: '||vdDateFrom);
     vdDateTo := '17/11/2001';
     dbms_output.put_line('Date To: '||vdDateTo);
     IF vdDateTo < vdDateFrom THEN
          RAISE E_STOP;
     END IF;
     vnDayFrom := to_char(vdDateFrom, 'dd');
     vnMonthFrom := to_char(vdDateFrom, 'mm');
     vnYearFrom := to_char(vdDateFrom, 'yyyy');
     vnDayTo := to_char(vdDateTo, 'dd');
     vnMonthTo := to_char(vdDateTo, 'mm');
     vnYearTo := to_char(vdDateTo, 'yyyy');
     IF vnMonthTo - vnMonthFrom < 0 THEN
          vnYearsDiff := vnYearTo - vnYearFrom - 1;
     ELSIF vnMonthTo - vnMonthFrom > 0 THEN
          vnYearsDiff := vnYearTo - vnYearFrom;
     ELSE
          IF vnDayTo - vnDayFrom >= 0 THEN
               vnYearsDiff := vnYearTo - vnYearFrom;
          ELSIF
               vnDayTo - vnDayFrom < 0 THEN
               vnYearsDiff := vnYearTo - vnYearFrom - 1;
          END IF;
     END IF;
     dbms_output.put_line('Years: '||vnYearsDiff);
     IF vnMonthTo - vnMonthFrom < 0 THEN
          IF vnDayTo - vnDayFrom >= 0 THEN
               vnMonthsDiff := 12 + vnMonthTo - vnMonthFrom;
          ELSIF
               vnDayTo - vnDayFrom < 0 THEN
               vnMonthsDiff := 12 + vnMonthTo - vnMonthFrom - 1;
          END IF;
     ELSIF vnMonthTo - vnMonthFrom = 0 THEN
          IF vnDayTo - vnDayFrom >= 0 THEN
               vnMonthsDiff := 0;
          ELSIF
               vnDayTo - vnDayFrom < 0 THEN
               vnMonthsDiff := 11;
          END IF;
     ELSE
          IF vnDayTo - vnDayFrom >= 0 THEN
               vnMonthsDiff := vnMonthTo - vnMonthFrom;
          ELSIF
               vnDayTo - vnDayFrom < 0 THEN
               vnMonthsDiff := vnMonthTo - vnMonthFrom - 1;
          END IF;
     END IF;
     dbms_output.put_line('Months: '||vnMonthsDiff);
     IF vnMonthFrom = vnMonthTo THEN
          vnDaysDiff := vnDayTo - vnDayFrom;
     IF vnDaysDiff < 0 THEN
     vnDaysDiff := to_char(last_day(add_months(vdDateTo,-1)),'dd') - vnDayFrom;
               IF vnDaysDiff < 0 THEN
                    vnDaysDiff := vnDayTo;
               ELSIF vnDaysDiff >= 0 THEN
                    vnDaysDiff := vnDaysDiff + vnDayTo;
               END IF;
     END IF;
     ELSE
          vnDaysDiff := vnDayTo - vnDayFrom;
     IF vnDaysDiff < 0 THEN
     vnDaysDiff := to_char(last_day(add_months(vdDateTo,-1)),'dd') - vnDayFrom;
               IF vnDaysDiff < 0 THEN
                    vnDaysDiff := vnDayTo;
               ELSIF vnDaysDiff >= 0 THEN
                    vnDaysDiff := vnDaysDiff + vnDayTo;
               END IF;
     END IF;
     END IF;
     dbms_output.put_line('Days: '||vnDaysDiff);
EXCEPTION
     WHEN E_STOP THEN
     dbms_output.put_line('Error: Date To is less than Date From.');
END;
Regards
Dinesh

Similar Messages

  • Why doesnt Adobe just UPDATE Flash Professional? Arent they reinventing the wheel?

    Congratulations on getting to open beta with Flash Catalyst!
    I know its late in the game to mention something like this but why didnt Abobe just update Flash Professional?
    It seems that the arguments for flash Catalyst center around the following:
    1) smooth workflow between Photoshop & Illustrator, especially because of the same layer view
    2) No coding required to create components out of artwork
    3) Can create FXG  and FXPs to be used in Flash Builder
    4) Can create multi screen aplications
    1) 2) and 3) could all be solved by adding a new types of symbols to Flash Professional's 3 currently available symbols(MovieClip, Button, Graphic)
    1) could be solved by adding a new Sprite symbol.
    Flash Professional needs to be updated to keep up with and match the structure of AS3 anyway.
    Sprites were added in AS3 and now wireframe components are being added to the code structure, why not just at that on the design side as well?
    Sprites are essentially MovieClips with out a timeline.
    So if you created a new Sprite symbol and opened it up in the timeline, you would only see one frame with folders and layers.
    A Sprite symbol is essentially organized the in layers and folders and would just like a photoshop file.
    And if you really want it to look like a Photoshop layout, then you just move the timeline view over to the right.
    This would solve problem 1.  Designers could import their artwork into Flash Professional as a Sprite and it would be a seemless experience.
    Obviously I'm not saying that a bitmap is a sprite. But I am saying that layers of bitmaps and could be organized inside of a Sprite. And the designer could turn any of the assets into a Button, MovieClip, Graphic, Sprite, and hopefully other Classes and WireframeComponents available in Flash.
    2)&3) could be solved by adding a new Symbols for the new Wireframe Components. The Button symbol already has a template with 4 states. Why not update Flash Professional to visually represent more Classes and Component Classes, instead of just the MovieClip Class and the Button Class. Even better, maybe there could be a way to make a template for creating our own wireframe components. Just assign a base class for the wireframe class and a base template, and the introspection view will display accordingly.
    States of the component would be listed out at the top instead of frames,  just like the Button Symbol used to be.  Different layers could be designated for specific graphical parts of the component. The designer would be free to add their own layers if necessary.
    In previous versions of Flash, everything was a movieclip and everthing had a timeline. Thats not the case anymore. The timeline is for intropecting MovieClips, but this view could be different when intropsecting different types of symbols such as Sprites, Buttons, Wireframe Components, and even Custom Wireframe Components(extensible).
    These new Symbols and also Sprites could export to FXG very easily.
    The multi screen applications in 4) look pretty similar to the Slide Presentation Template. Why not just make a new MultiScreen App Template and youre done. these MultiScreenApp Templates could exporte Screens to FXG or export the whole Template to a FXP.
    I applaud the work done on the new wireframe components and FXG. Great Job!
    But, just cant understand why you cant update Flash Professional with new types of Symbols(Sprites, new Buttons and wireframe Component Classes) and a new MultiScreen App Template.
    Flash Professional needs to keep up with AS3 and also needs to export FXG and FXP.
    Why doesnt Adobe focus on on this rather than create a new Tool? These features need to be added to Flash Professional anyway.
    Isnt there more of a disadvantage to having 2  tools for designers that do the same thing?
    I'm sure this issue has been debated before. Can anyone point to me links that have the arguments for creating a separate tool instead of updating?
    Has anyone ever suggested that Flash Professional should keep up with AS3?
    Has anyone ever suggested making Sprites a new symbol in Flash Professional so that it could be more seamless with Photoshop?
    Has anyone ever suggested make Wireframe components in Flash Professional like the Button Symbol in Flash Professional?
    Has anyone ever suggested updating Flash Professional so that it would export FXG and FXP?
    What is your opinion on this?
    -thomasglyn

    @Ross
    Thanks for your explanation. I appreciate your feedback.
    I'm glad we agree that ideally there should be 2 main tools, one for designers(Flash Professional) and one for programming(Flash Builder).
    You had mentioned "But, that assumes this is possible.  As it currently stands it is not" and the reason being "Catalyst, and Builder both use a completely different framework from Professional. The component architecture is drastically different, not to mention the entire backend of the software.".
    You could also argue that, the reasons to make a separate flex component creation tool like Flash Catalyst assumes that updating Flash Professional CS4 is NOT possible. But is the statement about the framework being entirely different really true?
    Well, that depends on what you mean by the term "framework".
    Framework can refer to 3 things in this case.
    1) the component framework
    2) the code framework(AS3)
    3) the flex framework (mxml, fxg)
    If you are refering to #1 then you're right, because Adobe hasnt updated the flash component framework in Flash Professional from Flex3 Halo components to Flex4 Spark components.
    Flash components have gone through many iterations, and the switch from AS2 to AS3 was probably more profound than the new wireless component structure(Spark). And now that we have AS3, isnt the only difficulty creating a intuitive UI in Flash Professional, and adding export features?
    If you are refering to #2 then I think you're incorrect, because Flash Professional has been updated to AS3 and Flex4 Spark components use AS3. I would totally agree with you, if CS4 did not go through all of the trouble updating to AS3.
    If you are refering to #3 then you're right, because Flash Professional doesnt export mxml, fxg, or fxp, but with a little creativity, it would probably be possible to allow such an export. Adding FXG/FXP export features could be solved by creating a new type of project file.  Adobe did this for AS2, AS3, flash lite, etc. Why cant they just make a new AS3/FXG file that only allows you to build fxg/fxp exportable assets.
    Why cant Adobe make a Sprite class the default document class for AS3/FXG projects and when some adds a movie clip asset, export movie clips as swfs or swcs?
    So to be honest, after opening up Flash Catalyst again and looking at it again, I almost get the feeling that its just a Flash Component creation tool with a Photoshop UI, for the new AS3/Flex 4 components(Spark components) that Adobe just refuses to add to CS4.  CS4 uses AS3 and Spark components use AS3.  CS4 needs to be a visual design tool for all the classes in AS3(as much as possible).
    Perhaps Adobe originally meant to name this product...
    ADOBE FLASH COMPONENTS
    Or maybe Adobe Flex Components(but thats no longer true, because Flex 4 will be Flash Builder).
    In regard to "reinventing the wheel". Flash components have been reinvented several times, and I totally agree with you that this is important to "reinvent" components to keep up with new techiques as2,as3,fxg.  You are right, this is a positive thing. However in this case, I am using "reinvent in a negative sense.
    So maybe I shouldnt say "reinvent the wheel", but "reinvent the car".
    Perhaps Adobe is trying to create a wheel for the upperclass RIA programmer Flex car, and isnt making it compatible common designer/programmer Flash car. And when they finished the wheel, and they decided just to make a Segway for the Designers and Flash people to ride, that uses this new wheel.
    You might argue that its more approachable for designers, and designers feel at home because the ui is similar. This is precisely why Adobe should hurry up and finish updating the ui of the Flash Professional IDE so that its ui is more compatable with Photoshop and Illustrator. The fact that Photoshop and Illustrator is the standard for designers are perhaps one of Adobe's greatest advantages.  They could make the designers happy if they just make a Sprite inspector view with layers like photoshop in Flash Professional, instead of using the old "everything
    is a movieclip" paridgim. Flash Professional has already upgraded to AS3 and in AS3 everything isnt a movieclip.  So it would be nice if they could make views for some of the new classes and wireframe components.
    This is the age old debate, update or start from scratch.  I guess I'm saying that I think the hard work of updating to AS3 has already been done, and its just plain wierd that Adobe decides to build a separte tool for components, when they use the same AS3 code base.
    Its just insanely exciting to just think about what could have been if Flash updated and brought on more Designers and at the same time linked in the Flex community. Thats what Flash has always been about! The meeting point between Designers and Programmers.
    To go this far and quit just because of components just leaves me blue.
    It seems that many projects stop at 80% complete and if the developers just spent the extra 20% on fine tuning things then they would have a very high quality product. In this case the remaining 20% is  components, ui, and export. I understand that there are probably many things I dont understand, especially when you through in marketing, and product life cycle.
    But I think Adobe could have done it, if they put as much effort into it as they did to make an entirely new product.
    Maybe we should make some noise before its too late.
    I'm still interested in seeing more links that show the logic behind the initial discussions of this debate when it was first decided.
    pls keep me posted.
    @nwfa & macsavers
    Yes, youre right. it does seem to be their plan.  I just hope they are just testing the waters.  Perhaps after they do the initial selling of Flash Compenents, then maybe they could offer a free update to CS4.
    As I mentioned above, the main reason designers feel at home is because of the UI of Flash Catalyst. UI's can be updated, and I believe Flash Professional can and should update itsui for the reasons I mentioned above.

  • Am I trying to reinvent the wheel?

    Hey, y'all-
    I just wanted to throw this out to the general Mainstage community and get some feedback on it. Apologies in advance for length and over-explanation. I'm a keyboardist/programmer in the theatre world, with semi-extensive background in Kurzweil (K2500/K2600) keyboard programming, and I'm attempting to shift my paradigm to Mainstage/VSTs because of the flexibility, quality of sounds, and (I thought) ease of configuration. I'm also a computer programmer/systems engineer from long ago. So, coming from the K2600 modality, here's what I'm used to:
    I have a set of instruments (what K2600 would call "programs"), which I build from keymapped samples, and maybe run through some DSP algorithms if I want to tweak them
    I then use the instruments in sequentially arranged patches (K2600 "setups") in various layered combinations with themselves and each other to create the running order for a show
    I have the ability within the show patches to do transpositions, volume/velocity alterations, and various magical hardware controller assignments
    Coming to Mainstage, I've found a lot of parallels to the things I'm used to from the K2600, but there are a few things that don't seem to translate. Mainstage doesn't seem to be intuitively set up to establish a set of instruments (each singly instanced in memory) that one can then refer to from the actual patches one is going to use. The workaround seems to be channel strip aliasing, but this is poorly documented, and carries with it the issue of not being able to make per-patch modifications easily. For example, if I want my strings to be highly present in one patch, and then just a faint layer with another instrument in a different patch, aliasing doesn't work that great. The workaround for THAT seems to be to assign the audio output of my instrument channel strips to a bus, and then put audio channel strips in the individual patches that take that bus as an input and make my specific changes to that audio strip. That's OK, I guess, but it seems a bit kludgey, and also seems to cause random audio drop-outs while creating patches that require a Mainstage restart. And I'm still confronted with the problem that, if I want to use one instrument multiple times within one patch, I can't alias the same channel strip more than once. Here's a rather complicated workaround I came up with to solve most of this:
    I put all my instrument channel strips at concert level, and assign each one a different audio output bus (but I delete the concert-level audio strips that are automatically created by doing that)
    I create keyboard hardware inputs for each instrument (and make them really tiny so they can hide in a corner unobtrusively), and make the MIDI input for each keyboard a different IAC bus (I make the IAC bus numbering the same as the audio output bus numbering, just to keep things simple, so, for example, IAC bus 1 is the input for the keyboard sending to Strings, and then Strings send their audio output to Mainstage bus 1)
    I make a patch set called "Base Patches", and then create a patch for each instrument within that set. The patch contains an external instrument strip that sends to the IAC bus corresponding to the instrument I want, and an audio strip that corresponds to the output of that instrument. Any sort of general processing I know I want to use as a "template" for that instrument I go ahead and implement in that audio strip.
    I make a new patch set called "Show Patches" and set up my running order. For each patch, I go and copy the external instruments and audio strips from Base Patches that correspond to the instruments I want to use in this particular patch, adjust the layering of the external instruments as I need to, and do any tweaking to the audio strips to suit this particular patch (relative volumes, controller stuff, extra FX)
    This seems to solve many of the problems I've encountered - I have at least a template for each instrument that I can easily copy, I'm only instancing each instrument in memory once, and I can layer instruments with themselves (for example, play strings in octaves or something like that). Here are the issues I have with this system:
    I'm limited to 32 different instruments because there are only 32 Mainstage buses. Now, granted, I probably won't need more than that or be able to fit more than that into RAM anyway, but still, it's a constraint.
    If I use the same instrument more than once in a patch (like in the octave strings example I cited above), I only have one output bus for all the layers in that patch for that instrument, since, for example, the Strings base patch has been assigned always to use bus 1. So, I can't necessarily get the level of granularity I want in adjusting things, like if I want one string layer in the patch to be loud and another one to be soft. I guess I could create a "Strings 2" base instrument to accommodate cases like that, but that seems like a waste of memory and Mainstage buses.
    The weird audio drop-outs when creating new patches still seem to happen and I have to restart Mainstage if I want to hear the results of what I'm programming.
    I have like 20 stupid tiny keyboards hanging out in my Mainstage layout. Not a big issue, but still aggravating.
    There's a lot to keep track of, and it seems unnecessarily complicated and maybe a little fragile. Like I'm asking the software to do something it's not basically designed to do.
    I guess I'm just looking for some feedback on this from people who know a lot more than me. (Assuming any of them have had the patience to read all this!) I'm sure all of these problems have shown up on this very forum many times, but I just haven't found a solution that seems to address all of them any better than this one. If this is the way I have to do things, that's OK, and I think I can live with it, but I just want to make sure that, if I'm gonna go around my rear end to get to my elbow, it's a worthwhile trip. Any constructive thoughts are appreciated. Thanks!

    HI,
    I am afraid to say I really think you are "reinventing the wheel" :-)
    Mainstage is so powerful, but takes a bit of knowledge on how to do the most common things the "mainstage way", not the traditional way we used to do on hardware synths and samplers.
    I am also on the musical theater world and have designed many setups for big productions here in Spain.
    To start with a simple answer to your multiple questions, you don't have to drag many keyboards on your mainstage screen to have multiple midi inputs; you just need to add a Midi Monitori tem (the small yellow ball), and it serves the sames as a keyboard, even allowing for multple sound layers and even keyboard splits.
    Secon, the busses option you are using is definetly limited and akward. From my point of view and experience I still have had no need for aliases or that kind of configuration, which takes a lot of tweaking for every little change. I would suggest to help you build a Mainstage file based on your needs, what you really want to do! You can write to my email if you want, [email protected]
    btw, you should describe which plug-ins and libraries are you using, as well as your mac specs.
    greetings,
    Valgreen

  • How to use custom nodes in a JTree without reinventing the wheel?

    Hello,
    Each node contains two JTextAreas in a Box layout and a few JButtons.
    I wish to display these nodes in a JTree.
    Reading the tutorial, it seems I would have to reimplement the TreeModel, TreeCellRenderer/Editor, MutableTreeNode interfaces etc.
    Can I use the DefaultTreeModel, and other standard widgets (great stuff!) to minimize the amount of reimplementation I must do. aka avoid reinventing the wheel? I was thinking of extending my node from the DefaultMutableTreeNode class - however it does not display the nodes with the TextAreas, buttons etc.
    any help appreciated.
    thanks,
    Anil

    was able to fix it over here:
    http://forum.java.sun.com/thread.jspa?messageID=4089777

  • How to determine the creation date/time for a file?

    The important operating systems maintain both a creation date/time and last modified date/time for files. But in the File class there is only a lastModified() method. How does one determine the creation date/time for a file?

    As far as i know, there is no way to know creation time, since it is a OS dependant information.

  • How can I make the current date/time be sent when emailing as XML?

    I'm creating a form for a customer to use for submitting print jobs. This customer will be emailing the XML form data, which will in turn be converted into a production order. I'd like to make the PDF form capture my customer's system time, so that I know when they filled out the form. I COULD just leave that up up the customer and use required current date and time fields, but that provides the ability for the customer to falsify that information.
    Is there any good way to capture the current date/time in the XML data, so that the customer doesn't need to nor has the ability to?
    Any suggestions would be great!

    You can use the following methods getHours(),getMinutes(), and getSeconds() from the date object to obtain the values for hour,minute,and second.
    Click here to see an example:
    http://66.34.186.88/LiveCycleSamples/.3bbc2f4b.pdf

  • Min,Max for a time Range and Sum of Records for the last date/time

    Hi All,
    I have a table with the following structure/data:
    create table  Events   (
                                        [EventID]       
    int                   NOT NULL,
                                        [Title]            
    nvarchar(200)  NOT NULL,
                                        [SourceName]  nvarchar(20)    NOT NULL,
                                        [Type]             
    int                  NOT NULL,
                                        [eDate]           
    datetime
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S07', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S08', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S09', 3,'2014-01-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S010', 3,'2014-01-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-01-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-01-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-02-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S02', 3,'2014-02-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-02-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-02-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-02-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-02-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-03-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S02', 3,'2014-03-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-03-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-03-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-03-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-03-01 00:00:00.000')
    And I wrote the following query:
     select EventID as [Event ID],
           Title, 
           count(distinct(SourceName)) as [Instances], 
           Type,
           min(eDate) as  [First Detected],
           max(eDate) as [Last Detected],
           datediff(d,min(eDate),max(eDate)) as [Delta (days)]
    from  Events
    where type = 3
    group by EventID, Title, Type
    having max(eDate) <> min(eDate)
       and max(eDate) =(select top 1 eDate from Events order by eDate desc)
    and I get the following results (see the instance number)
    Event ID Title         Instances Type First Detected                      Last Detected                    
       Delta (days)
    =============================================================================================================================
    100         Event 1         5         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000    
    59
    101         Event 2        
    3         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     59
    102         Event 3        
    2         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     59
    This is normal for this query however what I need to do is a little different.
    In other words, while I need to show when we recorded a specific event first and last time,
    I need to display the results for the last date/time when it was recorded. 
    For example what I need to provide should look like this:
    Event ID  Title                Instances        Type       First Detected                    
    Last Detected                          Delta (days)
    =============================================================================================================================
    100         Event 1            2                   3           
    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000      59
    101         Event 2            2                   3           
    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000      59
    102         Event 3           
    2                   3            2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     
    59
    Could you please help me to fix this query?
    TIA,
    John

    ;With cte As
    (Select EventID as [Event ID],
    Title,
    SourceName,
    Type,
    min(eDate) Over(Partition By EventID, Title, Type) as [First Detected],
    max(eDate) Over(Partition By EventID, Title, Type) as [Last Detected],
    eDate,
    datediff(d,min(eDate) Over(Partition By EventID, Title, Type),max(eDate) Over(Partition By EventID, Title, Type)) as [Delta (days)],
    max(eDate) Over() As MaxEDate
    from Events
    where type = 3)
    Select [Event ID],
    Title,
    COUNT(Distinct SourceName) As Instances,
    Type,
    [First Detected],
    [Last Detected],
    [Delta (days)]
    From cte
    Where eDate = MaxEDate And [First Detected] <> [Last Detected]
    Group By [Event ID],
    Title,
    Type,
    [First Detected],
    [Last Detected],
    [Delta (days)];
    Tom
    P.S. Thanks for providing the DDL and data.  That is always very helpful.

  • I delete an individual message but the time I received the message is still showing next to the persons name in my inbox instead of going back into the correct date/time order. Anyone know how to fix this?

    I delete an individual message but the time I received the message is still showing next to the persons name in my inbox instead of going back into the correct date/time order. Anyone know how to fix this?

    SOLUTION
    Open "terminal" on your mac and type the following:
    defaults write com.apple.mail IgnoreSortOrderWhenSelectingAfterDelete 1
    (copy and past the whole line)
    This will stop that behaviour in mail. 
    It works on most opperating systems.
    mine is.
    Mac OSx 10.7.2 Lion
    Cheers

  • I have lost the automatic date/time stamp

    I have lost the automatic date/time stamp when a form is submitted on my response page.  How do I make it start doing it again?  The column just appears blank now with new submissions.

    In the first cell of the column you need to re-enter the formula that used to be there.  Enter "= LOCALTIME(ROWCREATEDATE()".  You may need to change the date format after this.  Click on the Table button in the toolbar, select the Column with the dates, then select your prefered format.
    -Jeff

  • Converting Delivery Creation Date/Time into the Local Date/Time

    Hi
    I have two fields like 'Delivery Creation Date' and 'Delivery Creation Time' in ECC system . My user wants the Delivery Creation Date / Delivery Creation Time in Local time of Plants .
    For example :
    Delivery    Plant       DelivCreationDate       DelivCreationTime   DelivCreationDate(Local)   DelivCreationTime(Local)
    312456          1650               11/2/2007                     4:30                          11/2/2007                          3:30
    Here the Plant 1650 is in Mexico . The above delivery is created in Canada in ECC system according to the candain time .
    But user wants to convert the Candain Delivery Creation Date and Time into the Local Date/Time of specific plant .
    So we need to convert the  Candain Delivery Creation Date and Time into Mexico timings .
    How can it is possible this one and user wants to automate this process .
    Please let me know
    Mubeen

    DATA :
    timestamp like TZONREF-TSTAMPS,
    time like sy-uzeit,
    date like sy-datum.
    The following function module is used to convert the
    time and date into GMT timestamp
    CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP'
    EXPORTING
    i_datlo = <source_fields>-delivery_date
    i_timlo = <source_fields>-delivery_time
    I_TZONE = CAD'
    IMPORTING
    E_TIMESTAMP = timestamp.
    The following function module is used to convert the
    above obtained timestamp to MEX  timezone date and time.
    CALL FUNCTION 'IB_CONVERT_FROM_TIMESTAMP'
    EXPORTING
    i_timestamp = timestamp
    I_TZONE = MEX
    IMPORTING
    E_DATLO = date
    E_TIMLO = time.
    CAD and MEX are variables i have used...
    the challenge is to find the canadian and mexican time zone....CAD and MEX.
    which you can get by performing a lookup in table T001W and passing country as parameter.

  • How to get sqlplus to print the current date/time

    From a unix command line I can type:
    prompt> date; <any_Cmd>; date
    This will result in a timestamp being output before and after the command you inserted. Is there a way to make sqlplus print the current date/time after it is done executing an sql statment. This would be useful for me to know how long it took to execute and sql statement without watching it.
    Something like:
    SQL> select * from table; date;

    u cld set the following statements in sql*plus :
    sql>set time on
    sql>set timing on
    hope this solves ur problem.

  • Itunes it's not showing me the last date/time the iPhone/iPad was backed up.

    I just backed up my iPhone and iPad but  iTunes it's not showing me the last date/time my device was backed up. I had just done a backup about 3 hours ago. And when I go to check the backup location I see a folder there with the time it was last backed up. But it's not showing me the backup date in iTunes. I don't know what to do.
    I already tried to remove the folder in App. Support-Mobile Sync and start a brand new backup. But no date.
    Tried to delete and start a new iTunes folder in Music but nothing has changed
    Any solution is welcome!

    iCloud requires OS X Lion (10.7.2) or higher.  You will need to upgrade to either Lion higher in order to set up iCloud on your Mac.  First check to see if your system meets the system requirements to upgrade.
    Lion system requirements are:
    Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
    2GB of memory
    OS X v10.6.6 or later (v10.6.8 recommended)
    7GB of available space
    Mountain Lion requirements are shown here: http://support.apple.com/kb/HT5444.
    Mavericks requirements are shown here: http://support.apple.com/kb/HT5842.
    If you can run Mavericks, you can purchase an upgrade from the Mac App Store.  If you can only run Lion or Mountain Lion, contact the online store in your country and purchase a redemption code to download it from the Mac App Store.
    After upgrading, you will find iCloud in System Preferences>iCloud on your Mac, and can set it up as explained here: http://www.apple.com/icloud/setup/mac.html.
    Before upgrading, you may want to check the compatibility of your existing programs by checking here: http://roaringapps.com/apps:table.

  • To know the actual date & time for created versions in cprojects

    HI ABAPers,
    Am working on cproject version 3.1,  wanted to know where the  exact date & time  is getting captured when a version i.e
    con H & base  versions is created in cprojects ( collaboration projects ).
        Already i have checked in  dpr_project table where versions are getting stored with the same project created date & time. But not with the actual date & time when the versions were created. 
    is there any BAPI or table where we can know the actual date & time of the created versions.
    Thank you!!!
    Abdul

    Hi,
    According to your post, my understanding is that you want to change date format for ‘Created’ field in the getVersions web service.
    Per my knowledge, you can get the date format for ‘Created’ field as “MM/dd/yyyy HH:mm a”.
    For more information, you can refer to:
    Versions.GetVersions Method (Versions)
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Get the creation date time of the file located in persentation server

    Hi Experts,
    I have a requirement where i need to fetch the creation date time of a file.
    ex. file path :  C:\Documents and Settings\file.xml
    I have the file path, i need to know when this file is created.
    Is there any GUI services or FM to achieve this?
    Your help in this regard is highly appreciated.
    Kind Regards,
    Vidya

    Hi Sandeep,
    Thanks for your reply.
    Can you please explain in detail the procedure to Maintain a log table & fetching the
    creation date time of a file in persentation server.
    The requirement is :
    I have the directory path, which contains many xml files. ex : C:\Documents and Settings\Dir
    I have to fetch files ,which has been created between the specified time stamp.
    ex : October 24, 2008 to December 24, 2008
    So i need to fetch all the files from the directory "Dir" which has been created between
    October 24, 2008 to December 24, 2008.
    Regards,
    Vidya

  • Date / Time In SAP ... is it the server Date / Time ?

    Hi,
    If my understanding is all right, the date/time in SBO application is the date/time on the server...
    If I have many offices in the world and they wish to manage BP activities... Does that mean that the reminders will come
    up when the SERVER will be at the date / time of the activity and not when the local time will be the time of the activity ?
    Can I change the way things work  ?
    I've been told that the whole issue of time zones was discussed and this is resolved in the next release 8.8.  But Of course, it does not help right now...
    Do you think there is a workaround by the time we get upgraded to 8.8... ?
    thanks,
    Luce

    You are right, the date/time in SBO application is the date/time on the server.  As for the topic, you may check this thread:
    Re: Time Zone Differenz between users and SQL Server (Citrix)
    Thanks,
    Gordon

Maybe you are looking for

  • Abt Drop Down For ALV Data cells

    Hi, I m unable to create drop down for each cell of ALV table. Reply me as soon as possible. Thks.

  • Error message: You cannot save a completed copy of this form to your computer.

    Hello, I created a PDF form in Acrobat Pro X and i am trying to distribute it by placing it on our shared drive so employees can take it from there and save it to their own computer. I tested the form with some employees that have Reader. Some can op

  • Invoice cannot be reversed while PO is in approval or rejected

    Hi all I have an instance in R/3 of an invoice that I need to reverse. The purchase order was increased to cover this invoice but the invoice has now been paid by other means so is now not required. I cannot reverse the invoice when the purchase orde

  • I rented a movie and it keeps stopping

    i rented a movie off itunes and it keeps stopping every 30 min and takes for ever to play again, i have re launched my itunes many times but it wont help. how do i fix it?

  • How to use levels in RDF Data Model?

    I am working on RDF model, i am able to retrieve the queries base on subject or object.... i want to retrieve the data based on level. i could not get the query for that. would you please advice me regarding solving this issue. Thanks in Advance Kamr