Pure SQL to partition date-time occurrences into non-overlapping windows?

i've a question that so far, i've never been able to solve via a pure SQL option.
it's hard to explain in words, but it's something like this:
given a set of date-time, i would like to partition the data into non-overlapping windows of 30 minutes each.
the data is supposed to be partitioned into windows of 30 minutes, meaning when the data is within 30 minutes of the first occurrence, only the first occurrence will be returned. in the next second after the 30th minute, the record will be considered as the start of a new window and is also returned. so those data that occurs within the window period are suppressed. the first occurrence is not necessarily occurring on the 00th minute, so the window start will never be constant.
run the below query to look at the dummy data.
SELECT     'A' AS ID
          , TRUNC(SYSDATE) + 7 / 24 + 1 *(ROWNUM - 1) / 1440 AS datetime
      FROM DUAL
CONNECT BY ROWNUM <= 50
UNION ALL
SELECT     'A' AS ID
          , TRUNC(SYSDATE) + 9 / 24 + 8 / 1440 + 1 *(ROWNUM - 1) / 1440 AS datetime
      FROM DUAL
CONNECT BY ROWNUM <= 35
UNION ALL
SELECT     'B' AS ID
          , TRUNC(SYSDATE) + 7 / 24 + 5 *(ROWNUM - 1) / 1440 AS datetime
      FROM DUAL
CONNECT BY ROWNUM <= 15this is supposed to be the output.
ID     DATETIME
A     5/19/2010 07:00:00
A     5/19/2010 07:30:00
A     5/19/2010 09:08:00
A     5/19/2010 09:38:00
B     5/19/2010 07:00:00
B     5/19/2010 07:30:00
B     5/19/2010 08:00:00so far, i'm using a PL/SQL to pipe the records. but i would like to know if this is achievable via SQL or not.
i've tried looking at analytics, width_bucket, ntile and alll options i can think of, but i just can't solve this at all.

hey Bob,
your answer is most definitely correct and does what i want. i've verified it again my data set and it returns the results as required!
you've definitely proven me wrong. i was always under the impression that this wasn't possible. thanks!
just a small note:
i need the windows to be binned by seconds, so have changed the numtodsinterval to raw numbers.
WITH t AS
     (SELECT 'A' AS ID
            , TRUNC(SYSDATE) +(6.75 / 24) AS datetime
        FROM DUAL
      UNION ALL
      SELECT 'A' AS ID
            , TRUNC(SYSDATE) +(6.75 / 24) AS datetime
        FROM DUAL
      UNION ALL
      SELECT     'A' AS ID
                , TRUNC(SYSDATE) + 7 / 24 + 1 *(ROWNUM - 1) / 1440 AS datetime
            FROM DUAL
      CONNECT BY ROWNUM <= 50
      UNION ALL
      SELECT     'A' AS ID
                , TRUNC(SYSDATE) + 9 / 24 + 8 / 1440 + 1 *(ROWNUM - 1) / 1440 AS datetime
            FROM DUAL
      CONNECT BY ROWNUM <= 35
      UNION ALL
      SELECT     'B' AS ID
                , TRUNC(SYSDATE) + 7 / 24 + 5 *(ROWNUM - 1) / 1440 AS datetime
            FROM DUAL
      CONNECT BY ROWNUM <= 15)
    ,a AS
     (SELECT ID
            ,datetime
            ,LAG(datetime) OVER(PARTITION BY ID ORDER BY datetime) AS prevtime
            ,LAST_VALUE(datetime) OVER(PARTITION BY ID ORDER BY datetime RANGE BETWEEN CURRENT ROW AND 30 / 1440 + 1 / 86400 FOLLOWING) AS interval_end
        FROM t)
    ,b AS
     (SELECT ID
            ,datetime
            ,LEAD(datetime) OVER(PARTITION BY ID ORDER BY datetime) AS nexttime
        FROM t)
    ,ab AS
     (SELECT a.ID
            ,a.datetime
            ,a.prevtime
               ,a.interval_end
               ,b.datetime as b_datetime
            ,b.nexttime
        FROM a JOIN b ON(a.ID = b.ID
                         AND a.interval_end = b.datetime)
SELECT     ID
          ,datetime
      FROM ab
START WITH prevtime IS NULL
CONNECT BY ID = PRIOR ID
       AND datetime = PRIOR nexttime
  ORDER BY ID
          ,datetime;this most definitely proves that i'm still not sure of how to use hierarchy queries.
Edited by: casey on May 20, 2010 11:20 AM

Similar Messages

  • SQL query for date & time interval

    Hello everyone,
    there is my problem
    I have to make a search for events that are taking place during inserted date & time .
    There's the table structure:
    event
    datefrom
    dateto
    timefrom
    timeto
    The problem is, when I try:
    select * from xyz where datefrom <= inserted_date and dateto >= inserted_date and timefrom <= inserted_time and timeto >= inserted time;
    then I don't get back all records.
    eg: user inserts date = 10.10.2010 and time 10:00 and in the table is event [abc 11:00 9.10.2010 -> 09:00 11.10.2010] stored following way:
    event         abdc
    datefrom   09.10.2010
    dateto        11.10.2010
    timefrom    11:00
    timeto         09:00
    => this event won't be found, because the sql logic compares only single parameters and not their context.
    Do you have any idea, how to solve this issue?
    Thank you.
    Lukas

    Hello Hubert,
    thank you very much for your proposal, but your code makes the same select as mine (but in a more user friendly look :).
    Table:
    datefrom 09.10.2010
    dateto 11.10.2010
    timefrom 11:00
    timeto 09:00
    Event date = 10.10.2010 and time 10:00.
    Your query:
    select * from xyz where 10.10.2010 between 09.10.2010 and 11.10.2010 (that's so far ok) and 10:00 between 11:00 and 9:00 (no return there, because 10:00 doesn't lie within interval 11:00 -> 9:00... actually no value lies there) ;
    Don't you have any other idea?
    Thank you
    Lukas

  • Sql ---sum of Date-time formate ......

    id time
    1 1.20
    2 2.30
    3 4.20
    4 5.30
    5 1.00
    result expected = 14:40 or (if AM/PM so result is ???)
    how can i calculate the sum of time ???
    please give me some fast tricks of handling date/time formate in oracle....

    942425 wrote:
    id time
    1 1.20
    2 2.30
    3 4.20
    4 5.30
    5 1.00
    result expected = 14:40 or (if AM/PM so result is ???)
    how can i calculate the sum of time ???
    please give me some fast tricks of handling date/time formate in oracle....Hi,
    First you post in wrong forum. Please post at PL/SQL
    Before posting there close it and mark as answered.
    if your time is number data type then you can try this
    SELECT SUM(NVL(ROUND(TRUNC(DAC_OT_HOUR)+((TO_NUMBER (SUBSTR (DAC_OT_HOUR, INSTR (DAC_OT_HOUR,'.',1,1)+1)))/60)),0))
    FROM DA_CHECKHope this helps
    Hamid
    Mark correct/helpful to help others to get right answer(s).*

  • Importing ansi date time format into diadem

    Hi,
    I have an ANSI data log txt file with the time channel format  30/03/2006 15:51:08.846 and i am trying import into DIADEM  using the date/time format dd/mm/yyyy hh:nn:ss.fff , but when the file is imported, the time channel cells appear as NO VALUE. Can anybody help please ?
    AdeK

    Hi Adek,
    Here is a DataPlugin which loads your data file into DIAdem 10.2.  There are a number of advantages to using a DataPlugin over the ASCII Import Wizard, so long as your data files follow a similar data file structure.  To register the DataPlugin, just detach the ZIP file, unzip the URI file within, then double-click on the URI file in Windows Explorer.  After that, you will be able to load your TXT data files by dragging&dropping them directly from the NAVIGATOR tree view or Search Results into the Data Portal on the right hand side of DIAdem.  DataPlugins also support selective loading, register loading, reduced loading, and DataFinder indexing, so all of these immediately become available to you with your TXT files.  Note also that header lines 2-4 are now declared as both File and Group properties.
    Ask if you have questions using the DataPlugin,
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Adek_TXT.zip ‏2 KB

  • How ti save date/time info into .lvm

    Hi,
    i need to save date/time info (Date:Time) into one .lvm together with my other signals (dynamic data). any suggestions?
    it should look like this for example
    results.lvm:
    date/time signal 1 signal 2 signal 3
    01.01.2005/12:00 2.2 3.3 4.4
    01.01.2005/12:02 2.4 3.4 4.5
    01.01.2005/12:04............
    and so on for every loop.
    thanx in advance
    vedran divkovic

    The LVM Express VI was designed to be easy to used. To facilitate this, data formats are fixed and cannot be set by the user in the Express VI. You have several options to get the format you want.
    If you don't need all the header information in the LVM file, roll your own code. If you are only saving one line of code at a time, this is particularly easy. You will also need to write your own read code, assuming you are not just using Excel or something similar.
    Use the formatting capabilities of your analysis program to create the date code. Excel, for example, is perfectly happy to generate a time/date string based on a simple number. You may have to convert from LabVIEW absolute time to Excel absolute time, but that is fairly trivial. You can make a macro to do this.
    If you need the LVM header info, write the file using no data to get the header, then fill in your data with your own formatting. Read-back will be harder, since you will need to write that yourself. However, you can probably get most of the info from the LVM file read (maybe with an error), then read your own formatted data from the end of the file.
    WARNING: this one dives into vi.lib code. While you cannot change the formatting in the top level of an LVM file, the subroutines do take formats on a per-column basis. So, you can modify the original code to do what you want. Open the front panel, then search for ex_SignalsToSprdsheetStr.vi. Give it the format string you want and you are off. Note that this format will be in place everywhere you use the LVM code unless you save the entire hierarchy to a different location (using Save With Options->Development Distribution, include vi.lib files). Be very careful with this. You can easily get into cross-linking problems (linking VIs from the wrong location).
    One final comment. You can find the specification for the LVM file format in Specification for the LabVIEW Measurement File (.lvm), Version 1.0. It includes everything you didn't want to know about the LVM file format.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • SQL Query for date/time

    Hi All,
    I have a table containing data like this
    Person_name Time_spent Date/time
    ABC 5.5 16-sep-10 12:00
    ABC 3 16-sep-10 05:30
    ABC 2.5 17-sep-10 12:00
    ABC .5 16-sep-10 09:00
    What I want is to get data like this
    Person_name Time_spent Date/time
    ABC 9 16-sep-10
    ABC 2.5 17-sep-10
    what query i should run?
    Thanx
    Omy

    a query like this ...
    select sum(time_spent), person_name, trunc(date_time) from <table_name>
    group by person_name, trunc(date_time);
    HTH.

  • Problems converting FILETIME date/time into MM/DD/YYYY format...

    Has anyone successfully converted a FILETIME date/time value into a MM/DD/YYYY format using ColdFusion? I am failing drastically, and it seems like an easy conversion.
    FILETIME format (details: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284(v=vs.85).aspx) is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
    A database I'm working with has such values, and I want to display them in a user-friendly date format within my application.
    For example, one record is:
    13003368600
    The above number represents the following date and time:
    1/22/2013 @ 2:50 PM
    Sadly I know this only because the FILETIME value gets written to the database by a third-party application, and within that application I specify it in the MM/DD/YYYY format.
    Can anyone offer me some guidance, or better yet has anyone accomplished this already and want to share code?

    I did this, on cf9/linux, and it seemed to do the trick:
    <cfscript>
    Long = createObject("java","java.lang.Long");
    Date = createObject("java","java.util.Date");
    fileTimeToEpoch =
    // take pwdLastSet From Active Directory, it's in filetime
    pwdLastSet = JavaCast("long", Long.parseLong("130292682204519505"));
    // take filetime and turn it into epoch/java - 1970/1/1
    // http://www.silisoftware.com/tools/date.php - converted: jan 1, 1970 00:00 -00
    javaTime = JavaCast("long", pwdLastSet - 116444736000000000);
    // convert to milliseconds
    javaTime = JavaCast("long", javaTime / 10000);
    today = JavaCast("string", Date.init(javaTime));
    </cfscript>
    <cfdump var="#pwdLastSet#">
    <cfdump var="#javatime#">
    <cfdump var="#today#">

  • BI UDI data load conflict using MS SQL Server and date fields

    Hi BW Experts!
    We have found some unexpected problems when we are trying to perform a data extraction process from an SQL database (non-SAP application).
    We are using the BI UDI tool (JDBC Driver/Connector).    The basic data extraction works properly, however we have some specific problems to work with SQL Server fields defined as “Date Time”.
    The JDBC driver automatically intermediate the communication and translate these fields splitting the original SQL date time field into two separated fields with suffix “_D” (for date) and “_T” (for time).
    It works perfect for extraction, but it doesn’t work well when we try to restrict the data selection based on these fields.    
    When we put a date selection into the infopackage data selection area (we already have tried several date formats), the system simply ignores these selection parameters and send a SQL statement without “WHERE” clause to DBMS.   
    Please, anybody has experienced anything like this or know somethings that could help us? 
    This is a standard limitation from SAP BI UDI?
    Thanks in advance and best regards,

    Hi Matt and Thomas
    Many thanks for your replies.
    Yes I have to do the join. Even worse I have to write an Aggregate query like this!
    Select o.F1,o.F2, m.F1,m.F2, count(*)
    from
    table@oracleServer o,
    table@microsoftSQLServer m
    where o.F1=m.F1
    group by o.F1,o.F2, m.F1,m.F2;
    These are 2 different systems (hardware & software) which actually do the same job, they produce transactions for a common business entity. Kind of, both sell tickets for the same ABC ferry company.
    I can not put them side by side on the dashboard, as I need to aggregate the data and present it maybe in a Oracle BI Report for Accounting and Financial reconciliation purposes.
    The truth is, as it is. I can't change it, is too late.
    I have to device a way to harvest both systems as they are. I don't want to move around data. I thought looking at Oracle BI I could write SQL against multiple Data Sources. I am struggling to find a way. As it seems that it can "SQL query" 1 data source at a time.
    I have been hinted on another forum (OracleTURK) to use Oracle Transparent Gateways and Generic Connectivity. http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/toc.htm
    Shame, I have to pay licenses for OWB and Oracle Transparent Gateways. I thought DB vendors can do better. Why do I have to pay to access the other 50% of the market.
    I can understand the performance implications this might have. Because of it I might even be forced at the end to move data (ETL) into a separate database, slice it into partitions and manage it that way. Pitty because currenlty I only need one report out of these systems but seems like will be dear to get.
    Thank you for all your help.
    Kubilay

  • Convert date/time to a value in second

    Hello,
    I want to convert a basic date time variable into a numeric one corresponding to the time (in second) passed since January,1,1970 in order to put it in a SQL statment as a criteria.
    Is someone able to help me ?
    Regards

    If you have an java.util.Date object you can call getTime() method on it. It will return milliseconds. Just divide it on 1000. Here is example code:
    java.util.Date date = new java.util.GregorianCalendar(2001, 7, 6).getTime();
    long seconds = date.getTime() / 1000;
    //Your code
    Best regards, Alex.

  • Date/Time erros when working with Database Connectivity toolkit

    Hi!,
    We are observing errors with date/time when working with LV. The error occurs when the system datetime format is set such that day precedes month (e.g. dd/mm/yyyy). Our VI uses LV 7.1, Database Connectivity 1.0 and SQL Server 2000 on a Win2000 machine.
    Problem details
    Our database in SQL server has a table having columns with data type "datetime"
    If the system date format (as set in control panel) is "mm/dd/yyyy", the 'insert into database' vi works fine. This function inserts the date and time (among other things) into the above mentioned table.
    However, when the system datetime is set to dd/mm/yyyy we start receiving error that date and time is beyond range for dates in which the date had the day field greater than 12 (e.g. 23/10/2005). With the same settings, if the date is such that day field is equal or less than 12 (e.g. 03/10/2005), we do not receive an error but the date is interpreted as 10 March 2005 rather than 03 September 2005.
    Clearly LV (or is it SQL) is mistaking the day field as month.
    We have taken care that when sending and receiving date, the format date and time string is set as per system settings.
    Thus, if system setting is "dd/mm/yyyy" our format string is "%d/%m/%Y"
    And if the setting is "mm/dd/yyyy" our format string is"%m/%d/%Y"
    Any help on problem cause and cure is welcome.
    Thanks,
    Gurdas
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

    Hi Xu,
    You answer led me to some very interesting fact finding on how SQL server handles date and time. I have attached a zip file which contains webpages that throw more light on this issue.
    The attached pages tell me that SQL has an inbuilt date/time reference format. The default in mm/dd/yyyy. Which explains why my VI worked when I used that format to write to SQL.
    However there is a catch:
    SQL expects the date/time to be in its inbuilt reference format when you WRITE data to SQL. If the date/time is in a different format, better tell SQL about it by using say the SET command you mentioned.
    BUT what about the date/time format when you are reading data from SQL?
    Our finding is that SQL sends date/time string in the system date format when you READ from SQL !!! That is very surprising behaviour (why differentiate between write and read?).
    Is our finding correct?
    So, we adopted the following simple strategy (yet to be fully tested):
    1) Whenever we write date/time to SQL, the string is formatted as mm/dd/yyyy. Presently, the user's SQL server is in the default state. Caveat is that if the user changes SQL date/time from default (which is mm/dd/yyyy) to anything else, our software will give errors. But then he changed it  ;-)
    2) When we read date/time from SQL we format the string as per system date/time format.
    I know this is not very robust coding. But assuming the user keeps his SQL in the current setting, should we expect smooth working?
    In other words, are there any errors and/or flaws in our strategy?
    Thanks,
    Gurdas
    Gurdas Singh
    PhD. Candidate | Civil Engineering | NCSU.edu

  • How do I insert a 'date created' field into a template?

    I know that you can insert date & time fields into templates and make them auto-update whenever I open the document, but I am wondering if I can make the date field be set to the date when I created the document and then stay that date even if I reopen the file?
    In other words, is there a "Date Created" field?
    Thanks in advance for any help given.
    I am using Pages '09.

    I believe the date will either update always or never, depending on how you set it's options. I don't believe you will find an option for Update Once and Never Again.
    You will have to update the date upon creation and then set the option to not update. You can always find the creation date in the Document Inspector, Info tab, Show File info. You can also read this information in the Finder.
    Jerry

  • Update date/time in UNIX timestamp format

    The datetime in my Oracle DB is being stored in UNIX Date Time format.
    Is there a way I can set the date/time using an UPDATE statement in such a case.
    for eg:
    select id, creation_date, expiration_date from skel;
    id creation_date expiration_date
    400019 1213726470     
    400020 1213733052     
    400005 1210867973     
    400018 1213723608     
    I am looking to set the expiration date as creation_date + 1 year.
    Could you please advise?

    I am looking to update the value in the field. The values will still be in UNIX date/time format.Yes, but still: instead of continuing converting to Oracle dates and Unix dates, why not just store dates the way the datebase can deal with it the best?
    You're probably storing your UNIX date/time formatted dates in the database as NUMBERS.
    That is a great loss of lots of built-in date functionality Oracle Database provides.
    If you insist on staying on that road, then explore my previous links, you will find your answer:
    Convert epoch number to date, do arithmatic and convert the result back to epoch number.
    That is overkill.
    It won't work/scale/perform/whatever in the end. It is a bad approach.
    So, please reconsider this:
    Why are you storing dates as numbers?
    Convert those numbers to dates once, and be done with it for ever after and benefit from all the builtin date-functionality Oracle database comes with, or convince us that you really have a valid reason to store dates in UNIX date/time format into an Oracle Database.
    and my last date was...uuhhmm... never mind ;)

  • Changing date & time under eventlog

    Would like to know how to adjust date & time settings in the eventlog view for my Cisco 1400 bridge. Tx!

    There are two things going on here.
    1. When you change the capture date/time (Date Time Original), the change is immediately reflected in the EXIF portion of the Metadata panel in the Library module. Because this is a metadata change, the warning arrow appears on the thumbnail (if you have that set to show in the View Options)....and clicking on that arrow brings up the "Metadata changed, do you want to save to disk" dialog. Note that this happens when you do any kind of metadata change, not just changing the date/time. At that point you can either decide to write the metadata to disk, or not.....if you typically write your metadata changes to XMP I guess you'd say "Save", but if you don't then just ignore it. Of course if you say "Save" then Lightroom will do as requested and write the Metadata, if it's a DNG,JPEG,TIFF etc, the Metadata is written to the XMP section of the file header....but if it's a proprietary RAW then it's written to an XMP sidecar.
    2. The second thing is that if you have the option set in the Catalog Settings to write date/time changes into proprietary raw files, then the change that you make is reflected in the Raw file.....this is a different change to the XMP update.

  • Changing date/time ...

    I have a question about changing date and time ... thanks a lot in advance.
    I have .CR2 files and I want to change the "date time original" info ... I want to change this info in the raw file, so I clicked on the "write date or time changes to into proprietary raw files" check box in the catalog settings window ... and then, after changing date/time with the "edit capture time", Lightroom wants to save changes and after clicking the arrow on the thumbnail, it creates a sidecar file. If date/time changes is to write directly into raw file (because of catalog settings indicated above), why does Lightroom create sidecar .xmp file?

    There are two things going on here.
    1. When you change the capture date/time (Date Time Original), the change is immediately reflected in the EXIF portion of the Metadata panel in the Library module. Because this is a metadata change, the warning arrow appears on the thumbnail (if you have that set to show in the View Options)....and clicking on that arrow brings up the "Metadata changed, do you want to save to disk" dialog. Note that this happens when you do any kind of metadata change, not just changing the date/time. At that point you can either decide to write the metadata to disk, or not.....if you typically write your metadata changes to XMP I guess you'd say "Save", but if you don't then just ignore it. Of course if you say "Save" then Lightroom will do as requested and write the Metadata, if it's a DNG,JPEG,TIFF etc, the Metadata is written to the XMP section of the file header....but if it's a proprietary RAW then it's written to an XMP sidecar.
    2. The second thing is that if you have the option set in the Catalog Settings to write date/time changes into proprietary raw files, then the change that you make is reflected in the Raw file.....this is a different change to the XMP update.

  • Date/Time Picker Output Help

    In my Flex 3.6 app, I have a set of controls that allow the user to pick the date/time.  The user does this by selecting a date from a DateInput, an hour, minutes and AM/PM through three ComboBox.  I then combine the selections into a string and output in a Label control.
    I now need to compare the date/time selected to a set of date/times that are allowed.  I keep running into the error "1067: Implicit coercion of a value of type String to an unrelated type Date."
    How can I convert my date/time string into a valid date object so I can compare it with other date objects?
    Thanks!
    Lee
    Below is the code:
    DateTimePicker.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                            layout="absolute"
                                            minWidth="955"
                                            minHeight="600">
              <mx:Script>
                        <![CDATA[
                                  [Bindable]
                                  private var todayDate:Date=new Date();
                                  [Bindable]
                                  private var earliestTime:Date=new Date(todayDate.getTime() + 3 * 60 * 60 * 1000);
                                  [Bindable]
                                  private var latestTime:Date=new Date(todayDate.getTime() + 12 * 60 * 60 * 1000);
                        ]]>
              </mx:Script>
              <!--Data-->
              <mx:XML id="hoursXML"
                                  source="assets/hours.xml"/>
              <mx:XMLListCollection source="{hoursXML.hour}"
                                                                  id="xmllcHours"/>
              <mx:XML id="minutesXML"
                                  source="assets/minutes.xml"/>
              <mx:XMLListCollection source="{minutesXML.minute}"
                                                                  id="xmllcMinutes"/>
              <mx:DateFormatter id="dfd"
                                                        formatString="MM/DD/YYYY"/>
              <mx:Label x="10"
                                    y="10"
                                    text="Date/Time"/>
              <mx:DateField x="82"
                                              y="10"
                                              id="dfExpectedDate"
                                              text="{dfd.format(todayDate)}"
                                              selectableRange="{{rangeStart: this.earliestTime,rangeEnd: this.latestTime}}"
                                              visible="true"
                                              width="100"/>
              <mx:ComboBox x="200"
                                             y="10"
                                             id="cbExpectedHour"
                                             fontWeight="normal"
                                             width="80"
                                             text="Hour"
                                             selectedIndex="-1"
                                             dataProvider="{xmllcHours}">
              </mx:ComboBox>
              <mx:ComboBox x="300"
                                             y="10"
                                             width="80"
                                             id="cbExpectedMinute"
                                             fontWeight="normal"
                                             selectedIndex="-1"
                                             text="Minute"
                                             dataProvider="{xmllcMinutes}">
              </mx:ComboBox>
              <mx:ComboBox x="400"
                                             y="10"
                                             width="80"
                                             id="cbExpectedTimeRange"
                                             fontWeight="normal"
                                             selectedIndex="-1"
                                             text="AM/PM">
                        <mx:ArrayCollection>
                                  <mx:Object label="a.m."
                                                         data="AM"/>
                                  <mx:Object label="p.m."
                                                         data="PM"/>
                        </mx:ArrayCollection>
              </mx:ComboBox>
              <mx:Text x="10"
                                   y="38"
                                   text="{this.dfExpectedDate.text} {this.cbExpectedHour.text}:{this.cbExpectedMinute.text}:00 {this.cbExpectedTimeRange.selectedItem.data}"
                                   id="tExpectedLandingDateTime"
                                   visible="true"/>
    </mx:Application>
    hours.xml
    <?xml version="1.0" encoding="utf-8"?>
    <hours>
              <hour>12</hour>
              <hour>01</hour>
              <hour>02</hour>
              <hour>03</hour>
              <hour>04</hour>
              <hour>05</hour>
              <hour>06</hour>
              <hour>07</hour>
              <hour>08</hour>
              <hour>09</hour>
              <hour>10</hour>
              <hour>11</hour>
    </hours>
    minutes.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <minutes>
              <minute>00</minute>
              <minute>01</minute>
              <minute>02</minute>
              <minute>03</minute>
              <minute>04</minute>
              <minute>05</minute>
              <minute>06</minute>
              <minute>07</minute>
              <minute>08</minute>
              <minute>09</minute>
              <minute>10</minute>
              <minute>11</minute>
              <minute>12</minute>
              <minute>13</minute>
              <minute>14</minute>
              <minute>15</minute>
              <minute>16</minute>
              <minute>17</minute>
              <minute>18</minute>
              <minute>19</minute>
              <minute>20</minute>
              <minute>21</minute>
              <minute>22</minute>
              <minute>23</minute>
              <minute>24</minute>
              <minute>25</minute>
              <minute>26</minute>
              <minute>27</minute>
              <minute>28</minute>
              <minute>29</minute>
              <minute>30</minute>
              <minute>31</minute>
              <minute>32</minute>
              <minute>33</minute>
              <minute>34</minute>
              <minute>35</minute>
              <minute>36</minute>
              <minute>37</minute>
              <minute>38</minute>
              <minute>39</minute>
              <minute>40</minute>
              <minute>41</minute>
              <minute>42</minute>
              <minute>43</minute>
              <minute>44</minute>
              <minute>45</minute>
              <minute>46</minute>
              <minute>47</minute>
              <minute>48</minute>
              <minute>49</minute>
              <minute>50</minute>
              <minute>51</minute>
              <minute>52</minute>
              <minute>53</minute>
              <minute>54</minute>
              <minute>55</minute>
              <minute>56</minute>
              <minute>57</minute>
              <minute>58</minute>
              <minute>59</minute>
    </minutes>

    In my Flex 3.6 app, I have a set of controls that allow the user to pick the date/time.  The user does this by selecting a date from a DateInput, an hour, minutes and AM/PM through three ComboBox.  I then combine the selections into a string and output in a Label control.
    I now need to compare the date/time selected to a set of date/times that are allowed.  I keep running into the error "1067: Implicit coercion of a value of type String to an unrelated type Date."
    How can I convert my date/time string into a valid date object so I can compare it with other date objects?
    Thanks!
    Lee
    Below is the code:
    DateTimePicker.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                            layout="absolute"
                                            minWidth="955"
                                            minHeight="600">
              <mx:Script>
                        <![CDATA[
                                  [Bindable]
                                  private var todayDate:Date=new Date();
                                  [Bindable]
                                  private var earliestTime:Date=new Date(todayDate.getTime() + 3 * 60 * 60 * 1000);
                                  [Bindable]
                                  private var latestTime:Date=new Date(todayDate.getTime() + 12 * 60 * 60 * 1000);
                        ]]>
              </mx:Script>
              <!--Data-->
              <mx:XML id="hoursXML"
                                  source="assets/hours.xml"/>
              <mx:XMLListCollection source="{hoursXML.hour}"
                                                                  id="xmllcHours"/>
              <mx:XML id="minutesXML"
                                  source="assets/minutes.xml"/>
              <mx:XMLListCollection source="{minutesXML.minute}"
                                                                  id="xmllcMinutes"/>
              <mx:DateFormatter id="dfd"
                                                        formatString="MM/DD/YYYY"/>
              <mx:Label x="10"
                                    y="10"
                                    text="Date/Time"/>
              <mx:DateField x="82"
                                              y="10"
                                              id="dfExpectedDate"
                                              text="{dfd.format(todayDate)}"
                                              selectableRange="{{rangeStart: this.earliestTime,rangeEnd: this.latestTime}}"
                                              visible="true"
                                              width="100"/>
              <mx:ComboBox x="200"
                                             y="10"
                                             id="cbExpectedHour"
                                             fontWeight="normal"
                                             width="80"
                                             text="Hour"
                                             selectedIndex="-1"
                                             dataProvider="{xmllcHours}">
              </mx:ComboBox>
              <mx:ComboBox x="300"
                                             y="10"
                                             width="80"
                                             id="cbExpectedMinute"
                                             fontWeight="normal"
                                             selectedIndex="-1"
                                             text="Minute"
                                             dataProvider="{xmllcMinutes}">
              </mx:ComboBox>
              <mx:ComboBox x="400"
                                             y="10"
                                             width="80"
                                             id="cbExpectedTimeRange"
                                             fontWeight="normal"
                                             selectedIndex="-1"
                                             text="AM/PM">
                        <mx:ArrayCollection>
                                  <mx:Object label="a.m."
                                                         data="AM"/>
                                  <mx:Object label="p.m."
                                                         data="PM"/>
                        </mx:ArrayCollection>
              </mx:ComboBox>
              <mx:Text x="10"
                                   y="38"
                                   text="{this.dfExpectedDate.text} {this.cbExpectedHour.text}:{this.cbExpectedMinute.text}:00 {this.cbExpectedTimeRange.selectedItem.data}"
                                   id="tExpectedLandingDateTime"
                                   visible="true"/>
    </mx:Application>
    hours.xml
    <?xml version="1.0" encoding="utf-8"?>
    <hours>
              <hour>12</hour>
              <hour>01</hour>
              <hour>02</hour>
              <hour>03</hour>
              <hour>04</hour>
              <hour>05</hour>
              <hour>06</hour>
              <hour>07</hour>
              <hour>08</hour>
              <hour>09</hour>
              <hour>10</hour>
              <hour>11</hour>
    </hours>
    minutes.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <minutes>
              <minute>00</minute>
              <minute>01</minute>
              <minute>02</minute>
              <minute>03</minute>
              <minute>04</minute>
              <minute>05</minute>
              <minute>06</minute>
              <minute>07</minute>
              <minute>08</minute>
              <minute>09</minute>
              <minute>10</minute>
              <minute>11</minute>
              <minute>12</minute>
              <minute>13</minute>
              <minute>14</minute>
              <minute>15</minute>
              <minute>16</minute>
              <minute>17</minute>
              <minute>18</minute>
              <minute>19</minute>
              <minute>20</minute>
              <minute>21</minute>
              <minute>22</minute>
              <minute>23</minute>
              <minute>24</minute>
              <minute>25</minute>
              <minute>26</minute>
              <minute>27</minute>
              <minute>28</minute>
              <minute>29</minute>
              <minute>30</minute>
              <minute>31</minute>
              <minute>32</minute>
              <minute>33</minute>
              <minute>34</minute>
              <minute>35</minute>
              <minute>36</minute>
              <minute>37</minute>
              <minute>38</minute>
              <minute>39</minute>
              <minute>40</minute>
              <minute>41</minute>
              <minute>42</minute>
              <minute>43</minute>
              <minute>44</minute>
              <minute>45</minute>
              <minute>46</minute>
              <minute>47</minute>
              <minute>48</minute>
              <minute>49</minute>
              <minute>50</minute>
              <minute>51</minute>
              <minute>52</minute>
              <minute>53</minute>
              <minute>54</minute>
              <minute>55</minute>
              <minute>56</minute>
              <minute>57</minute>
              <minute>58</minute>
              <minute>59</minute>
    </minutes>

Maybe you are looking for