Sql date time

hi i have a date time field in ms sql server 2005
i have 2 form fields i need to insert into the datetime
i am using CAST(@SchDateTime AS DATETIME) to convert my
datetime from
#DateFormat("#form.SMS_Date# #form.SMS_Time#",'dd/mm/yyyy
hh:mm:ss')#
but the time is not inserting correctly any ideas how i
insert 2 form fields into sql ?
many thanks

KeithLaw999 wrote:
> the time is not inserting correctly
What does not correctly mean?
> #DateFormat("#form.SMS_Date#
#form.SMS_Time#",'dd/mm/yyyy hh:mm:ss')#
DateFormat parses a date value (not a date and time). It uses
US date formats. So "12/2/2007" will be considered December 2nd,
not February 12th. Also, is your time using a 12-hour or 24-hour
clock? It its a 12-hour clock sql server might assume AM, unless
you included a time marker (ie AM or PM).
> am using CAST(@SchDateTime AS DATETIME) to convert my
datetime
Convert() provides more control, but I don't know if
dd/mm/yyyy hh:mm:ss is one of the supported styles. An alternative
is to use CF to parse the strings into a valid datetime object
first, instead of passing a string to sql server and letting it do
the parsing.

Similar Messages

  • Convert Data type from Oracle Data time string to SQL Date time data type

    I have a time stamp column pulled from oracle into a SQL server db table varchar datatype column.
    Now i want to change that column to date time.
    Following is the data present in the table:
    01-APR-11 02.15.00.026000 AM -08:00
    01-APR-11 04.15.00.399000 AM -08:00
    01-APR-11 06.15.00.039000 AM -08:00
    I want to convert this data into sql server datetime data type.
    Please advice.
    Thanks,
    Sam.
    I am unable to find the solution in other sites which is why I have posted it in Oracle forum for seeking solution.
    Thanks in Advance.
    Sam.

    Sam,
    How are you actually loading the data into SQL*Server - are you using something like an Oracle gateway, BCP or another Microsoft utility of some sort ?
    If you are using an Oracle problem then we may be able to help but if using a Microsoft utility then you should really follow up with Microsoft to know what format the data should be in to use a Microsoft utility.
    Regards,
    Mike

  • Sql date time insert error

    Hi i am having trouble entering a date in to a sql stored
    procedure.
    first i convert the date to the users current datetime using
    <cfscript>
    userTZ="#qGetClubDetails.LocalTime12#"; // or whatever tz ID
    you need
    tz=createObject("component","timeZone");
    userDateTime=tz.castFromServer(today,userTZ);
    </cfscript>
    then i need to insert this into a stored procedure using
    <cfstoredproc procedure="xsp_InsertSmsRecords"
    datasource="#application.ds#">
    <cfprocparam type="In" cfsqltype="CF_SQL_DATETIME"
    dbvarname="UsersDate" value="#CREATEODBCDATETIME(userDateTime)#"
    null="No">
    </cfstoredproc>
    but i am getting a error of
    Macromedia][SQLServer JDBC Driver][SQLServer]Error converting
    data type varchar to datetime.
    any ideas what i need to do?

    quote:
    Originally posted by:
    craiglaw98
    ok i have tried that with no luck, i did a cfdump on
    userDateTime and i got
    {ts '2008-01-21 05:16:04'}
    any ideas what i need to do to insert this to sql server
    Looks ok to me. To troubleshoot this, try using cfquery for
    your insert instead of a stored procedure.

  • Oracle SQL- Date/Time Help

    Hi I have a query that generates a roster report.
    The issue I am having is how do I create a query the runs off the start and end time.
    What I mean by this is, no matter what time of the day it is, I want the query to run based off of the between time of start and end, if that makes sense.
    Below is an example, notice the double entry, (and yes it is correct) the issue is that both these records get picked up, I would like my query to be based off what the time of day is.
    If it is 12PM, to send 1st record, if its 1:46 pm, to send 2nd record, not both.
    Any help... please
    Employee ID First Last Unit Abr Staffing Start Dt Staffing End DT wstat_name_ch wstat_type_no_in
    '015428'     Jason     Xi     'P23'     '2012-09-10 11:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          3
    '015428'     Jason     Xi     'P77'     '2012-09-10 13:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          1
    --My query for above statement.
    SELECT DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
    DBA.Resource_Master_Tbl.RscMaster_FName_Ch, DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.wstat_cde_tbl.wstat_type_no_in
    FROM DBA.resource_tbl, DBA.Resource_Master_Tbl, DBA.staffing_tbl, DBA.wstat_cde_tbl, DBA.position_tbl, DBA.unit_tbl
    WHERE DBA.resource_tbl.RscMaster_No_In = DBA.Resource_Master_Tbl.RscMaster_No_In AND DBA.resource_tbl.rsc_no_in = DBA.staffing_tbl.rsc_no_in AND
    DBA.staffing_tbl.wstat_no_in = DBA.wstat_cde_tbl.wstat_no_in AND DBA.staffing_tbl.pos_no_in = DBA.position_tbl.pos_no_in AND
    DBA.position_tbl.unit_no_in = DBA.unit_tbl.unit_no_in AND (DBA.staffing_tbl.staffing_start_dt <= NOW()) AND
    (DBA.staffing_tbl.staffing_end_dt >= NOW()) AND (DBA.wstat_cde_tbl.wstat_type_no_in = 1 OR
    DBA.wstat_cde_tbl.wstat_type_no_in = 3)
    GROUP BY DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch, DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
    DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_type_no_in
    ORDER BY DBA.Resource_Master_Tbl.RscMaster_FName_Ch

    958211 wrote:
    Hi I have a query that generates a roster report.
    The issue I am having is how do I create a query the runs off the start and end time.
    What I mean by this is, no matter what time of the day it is, I want the query to run based off of the between time of start and end, if that makes sense.
    Below is an example, notice the double entry, (and yes it is correct) the issue is that both these records get picked up, I would like my query to be based off what the time of day is.
    If it is 12PM, to send 1st record, if its 1:46 pm, to send 2nd record, not both.
    Any help... please
    Employee ID First Last Unit Abr Staffing Start Dt Staffing End DT wstat_name_ch wstat_type_no_in
    '015428'     Jason     Xi     'P23'     '2012-09-10 11:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          3
    '015428'     Jason     Xi     'P77'     '2012-09-10 13:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          1
    --My query for above statement.
    SELECT DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
    DBA.Resource_Master_Tbl.RscMaster_FName_Ch, DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.wstat_cde_tbl.wstat_type_no_in
    FROM DBA.resource_tbl, DBA.Resource_Master_Tbl, DBA.staffing_tbl, DBA.wstat_cde_tbl, DBA.position_tbl, DBA.unit_tbl
    WHERE DBA.resource_tbl.RscMaster_No_In = DBA.Resource_Master_Tbl.RscMaster_No_In AND DBA.resource_tbl.rsc_no_in = DBA.staffing_tbl.rsc_no_in AND
    DBA.staffing_tbl.wstat_no_in = DBA.wstat_cde_tbl.wstat_no_in AND DBA.staffing_tbl.pos_no_in = DBA.position_tbl.pos_no_in AND
    DBA.position_tbl.unit_no_in = DBA.unit_tbl.unit_no_in AND (DBA.staffing_tbl.staffing_start_dt <= NOW()) AND
    (DBA.staffing_tbl.staffing_end_dt >= NOW()) AND (DBA.wstat_cde_tbl.wstat_type_no_in = 1 OR
    DBA.wstat_cde_tbl.wstat_type_no_in = 3)
    GROUP BY DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch, DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
    DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_type_no_in
    ORDER BY DBA.Resource_Master_Tbl.RscMaster_FName_ChFor your own sanity, you should learn to format your code. For the sanity of those of whom you are requesting assistance, you should preserve that formatting with the use of the code tags
    SELECT
        DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
        DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
        DBA.Resource_Master_Tbl.RscMaster_LName_Ch,
        DBA.unit_tbl.unit_abrv_ch,
        DBA.staffing_tbl.staffing_start_dt,
        DBA.staffing_tbl.staffing_end_dt,
        DBA.wstat_cde_tbl.wstat_name_ch,
        DBA.wstat_cde_tbl.wstat_abrv_ch,
        DBA.wstat_cde_tbl.wstat_type_no_in
    FROM
        DBA.resource_tbl,
        DBA.Resource_Master_Tbl,
        DBA.staffing_tbl,
        DBA.wstat_cde_tbl,
        DBA.position_tbl,
        DBA.unit_tbl
    WHERE
        DBA.resource_tbl.RscMaster_No_In = DBA.Resource_Master_Tbl.RscMaster_No_In
    AND DBA.resource_tbl.rsc_no_in = DBA.staffing_tbl.rsc_no_in
    AND DBA.staffing_tbl.wstat_no_in = DBA.wstat_cde_tbl.wstat_no_in
    AND DBA.staffing_tbl.pos_no_in = DBA.position_tbl.pos_no_in
    AND DBA.position_tbl.unit_no_in = DBA.unit_tbl.unit_no_in
    AND (DBA.staffing_tbl.staffing_start_dt <= NOW())
    AND (DBA.staffing_tbl.staffing_end_dt >= NOW())
    AND (DBA.wstat_cde_tbl.wstat_type_no_in = 1
         OR
         DBA.wstat_cde_tbl.wstat_type_no_in = 3)
    GROUP BY
        DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
        DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
        DBA.Resource_Master_Tbl.RscMaster_LName_Ch,
        DBA.unit_tbl.unit_abrv_ch,
        DBA.wstat_cde_tbl.wstat_name_ch,
        DBA.wstat_cde_tbl.wstat_abrv_ch,
        DBA.staffing_tbl.staffing_start_dt,
        DBA.staffing_tbl.staffing_end_dt,
        DBA.wstat_cde_tbl.wstat_type_no_in
    ORDER BY
        DBA.Resource_Master_Tbl.RscMaster_FName_ChI'm not sure the above is even legal Oracle SQL. Are you sure you aren't taking code from some other rdbms?

  • Date/Time in SQL

    Hey,
    I'm trying to get CF to put the date or date/time into the SQL 2000 date/time field by using Toolbox insert record form wizard. Then use the date picker on the date field.
    my error was
    Error Executing Database Query.
    [Macromedia][SQLServer JDBC Driver][SQLServer]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
    the SQL date/time field is 8 characters long, so, I don't know the best way to go about shoving a date/time into it in CF.
    Thanks in advance!

    Hi Kenneth,
    I´m by no means a CF expert, but...
    the SQL date/time field is 8 characters long, so, I don't know the best way to go about shoving a date/time into it in CF
    ...do your ADDT Control Panel´s *database* "Date format" and "Time formats" settings match the required SQL 2000 date/time format ?
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Any latest addition regarding java.sql.Date

    I have separate strings "10/21/2003" and "02:33:27".
    Just to convert String "10/21/2003" to sql date, do I really need to call up simple date format and parsing it?
    why? there is no time associated with this string. The time is on a separate string.
    I am using preparedstatement.

    Did I do unnecessary steps in getting to sql.Date ?
    String sDate = "10/16/2003";
    String sTime = "02:12:54:;
    String year = sDate.substring(6,9);
    String month = sDate.substring(0,1);
    String day = sDate.subst....
    String sDateNew = year + "-" + month + "-" + day;
    // the string becomes 2003-10-16.
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
    java.util.Date uDate = sdf.parse(sDateNew);
    long time = uDate.getTime();
    java.sql.Date sqlDate = new java.sql.Date(time);
    pstmt.setDate(i, sqlDate);
    It works, but did I put in extra steps ?
    I tried using the same trick for sTime, but that did not work out.

  • Insert current date/time problem in ViewObject

    Hi!
    I'm trying to setAttribute to a Date type field.
    I have a method:
    public String getCurrDateString() throws ParseException, java.sql.SQLException {
    SimpleDateFormat formatter = new SimpleDateFormat ("dd-MMM-yyyy hh:mm:ss aa");
    Date currentTime_1 = new Date();
    return formatter.format(currentTime_1);
    All the time i call this method such as:
    HistoryViewImpl histVO=getHistoryView();
    Row r=histVO.createRow();
    r.setAttribute("Entrydatetime",cp.getCurrDateString());
    I get oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value:19-Jun-2002 10:14:33 AM
    the strange thing is, that Oracle recognizes this kind of format, because if I use different pattern such as "yyyy-MM-dd", which returns string "2002-06-19", r.setAttribute("Entrydatetime",cp.getCurrDateString()) method works fine and in Oracle table field we have inserted value 19-Jun-2002 12:00:00 PM. The problem is, that i don't need 12:00:00 PM as a time, i need current time.
    What am i doing wrong? Or does it mean that oracle.jbo.domain.Date doesn't know format "dd-MMM-yyyy hh:mm:ss aa"?

    Hi!
    I'm trying to setAttribute to a Date type field.
    I have a method:
    public String getCurrDateString() throws ParseException, java.sql.SQLException {
    SimpleDateFormat formatter = new SimpleDateFormat ("dd-MMM-yyyy hh:mm:ss aa");
    Date currentTime_1 = new Date();
    return formatter.format(currentTime_1);
    All the time i call this method such as:
    HistoryViewImpl histVO=getHistoryView();
    Row r=histVO.createRow();
    r.setAttribute("Entrydatetime",cp.getCurrDateString());Instead of passing in the "String" pass the date object as is. oracle.jbo.domain.Date should be able to convert java.sql.Date/Time/Timestamp and store the time bits as set.
    If you have to pass in string, then establish a Formatter on the attribute with appropriate date format and then use the AttributeHints interface from the relevant AttributeDef object on the row to parse the input String into a valid parsed object that you can set into the row.
    (See oracle.jbo.uicli.binding.JUCtrlValueBinding.setAttributeInRow() method for a complete usage - source in bc4j\src\bc4juisrc.zip)
    I get oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value:19-Jun-2002 10:14:33 AM
    the strange thing is, that Oracle recognizes this kind of format, because if I use different pattern such as "yyyy-MM-dd", which returns string "2002-06-19", r.setAttribute("Entrydatetime",cp.getCurrDateString()) method works fine and in Oracle table field we have inserted value 19-Jun-2002 12:00:00 PM. The problem is, that i don't need 12:00:00 PM as a time, i need current time.
    What am i doing wrong? Or does it mean that oracle.jbo.domain.Date doesn't know format "dd-MMM-yyyy hh:mm:ss aa"?

  • 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

  • Date & time in sql through jdbc URGENT!!!

    hi,
    How do I enter date & time in this format "16 MAR 2002 12:54:23 pm" in the database of oracle through jdbc-sql?
    Please help me out.
    Its urgent.
    Regards
    Deepa Datar

    If you are familiar with Oracle, you can use PL/SQL to do the work for you. I didn't test this, but it's probably pretty close.
    String sql = "INSERT INTO TBLA
    VALUES(TO_DATE('16 MAR 2002 12:54:23 P.M.','DD MON YYYY HH24:MI:SS P.M.'))";
    I'm assuming that you know how to insert data, you are only wondering about the specifics of dates?
    This can also be done using a prepared statement. You would code the insert statement something like this:
    String sql = "INSERT INTO TBLA
    VALUES(TO_DATE(?,'DD MON YYYY HH24:MI:SS P.M.'))";
    I would suggest that if you can convert the time military (24 hour) time, it is easier to handle. The data format model for this is HH24. Otherwise you will need two prepared statements, one for A.M. and one for P.M.
    Good luck.

  • 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

  • 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

  • Sql command not working with date time??

    I am using my own sql query to fetch data in the sql command.
    Due to the problem I found - here is the basic example:
    The sql is:
    select to_number(to_date('10/11/2011 10:23:00','dd/mm/yyyy hh24:mi:ss') - to_date('10/11/2011 10:20:00','dd/mm/yyyy hh24:mi:ss'))  minu  from dual
    But I am not getting anything in Crystal Report tool!!
    In any sql tool I get results.
    When I am not using time part (hh24:mi:ss) :
    select to_number(to_date('10/11/2011','dd/mm/yyyy') - to_date('09/11/2011','dd/mm/yyyy'))  minu
    from dual
    I am getting data!!!!
    What is the problem??
    Initially I had it with parameters of type 'Date Time'
    Please, any one knows what the problem is?

    Hi,
    Sorry for the delay and thanks for answering.
    It was partial solution
    Moving to oracle driver, not (OLE DB), this specific one worked fine:
    select to_number(to_date('10/11/2011 10:23:00','dd/mm/yyyy hh24:mi:ss') - to_date('10/11/2011 10:20:00','dd/mm/yyyy hh24:mi:ss'))*100 minu from dual
    BUT
    When I tried to change one of the hardcoded values to be parameter of type 'Date Time' I couldn't pass the validation step - mostly the errors:
    "ORA 00900 Invalid sql statment"   and
    "ORA - 00907: Missing right parnthesis"
    No matter which format I used.
    Last version is:  
    select to_date('{?tsStartReport}','yyyy-mm-dd hh24:mi:ss') from dual
    Any idea why 'Date Time; is so problematic? How can I workaround it?

  • UPDATE SQL query using WHERE and a date/time data type... Multiple changes...

    I'm using the LabView Database Connectivity Toolset and am using the following query...
    UPDATE IndexStation
    SET Signal_Size=200
    WHERE 'StartTime=12:05:23'
    Now the problem is that this command seems to update all rows in the table IndexStation... Not just specifically the row where StartTime=12:05:23
    I have tries all sorts of {} [] / ' " around certain characters and column names but it always seems to update all rows...
    I've begun to use the SQL query tab in Access to try and narrow down as to why this happens, but no luck!
    Any ideas!?
    Thanks,
    Chris.

    Chris Walter wrote:
    I completely agree about the Microsoft issue.
    But it seems no SQL based manual states that { } will provide a Date/Time constant.
    Is this an NI only implementation? Because I can't seem to get it to function correctly within LabView or in any SQL query.
    Chris.
    There is nothing about the database toolkit in terms of SQL syntax that would be NI specific. The database Toolkit simply interfaces to MS ADO/DAO and the actual SQL syntax is usually implemented in the database driver or database itself although I wouldn't be surprised if ADO/DAO does at times munch a bit with that too.
    The Database Toolkit definitely does not. So this might be a documentation error indeed. My understanding of SQL syntax is in fact rather limited so not sure which databases might use what delimiters to format date/time values. I know that SQL Server is rather tricky thanks to MS catering for the local date/time format in all their tools and the so called universal date/time format has borked on me on several occasions.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • GregorianCalendar datetime format convert to  sql server date time format

    please help me
    my GregorianCalendar date time format is like this. *08/01/29 02:25:59* . I try to insert my database(sql server 2000 )
    data type is datetime ,in my database table display like this *2029-08-01 02:25:59.000* .can you help me to insert correct date in my database table like ( . *08/01/29 02:25:59*)

    use [PreparedStatement |http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html] and setTimestamp:
    [http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html]

  • How to set defalut value to DB current date time in EO using sql

    HI,
    I am using below query to set default date time as DB current date
    select to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS') from dual
    but it is throwing exception
    (oracle.jbo.AttributeLoadException) JBO-27021: Failed to load custom data type value at index 7 with java object of type oracle.jbo.domain.Timestamp due to java.sql.SQLException.

    Halo,
    I tested it & was able to find the values inserted in db in hiredate column.. What is that you did? Was this..
    In EO of emp -- Hire date column of datatype timestamp :
    details tab.. Default value -- expression :
    DBTransaction.currentDbTimeIf you would have done this,
    On run time when we click createInsert button , by default you will see the date.. After committing the changes, query it in db and will find the inserted record with default value..
    Sample data i tested :
    SQL Statement which produced this data:
      select * from emp where empno=1111
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    1111,null,null,null,06/05/2013 17:18:41,4500,null,nullRegards,
    Archana

Maybe you are looking for

  • OBIEE 11g - issue when export hierarchy to a csv

    Hello, I have an issue when I try to export to a csv file a report containing a Logical Dimension field, when I export just the first level of hierarchy is exported and not all the records. When I export to another format (such as excel) all the reco

  • Bug? iTunes forced me to encrypt backup - I don't want this. How can I stop it?

    It's all in the title really... When I just did the latest sync of my wife's phone, iTunes insisted that the backup needs to be encrypted. I looked down, the option is unchecked. It has never been checked. I unplugged the phone. I shutdown itunes and

  • Upgrading to uber SDO_GEOMETRY, looking for comments

    Good morning folks, I see the new thread from Dalibor discussing an issue with what I am calling "uber" SDO_GEOMETRY - anyone got a better name? Uber SDO_GEOMETRY is described here http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_mi

  • How call web Services in web dynpro abap ..?

    hi guru, how to call web service in wd abap ? wheather it is possible or not,if it possible please give me a exqmple Regard,s Vivekananthan.S

  • Mac hardware test and what this means

    My Imac started to freeze, I tried to reinstall tiger but the install just hung. So I decided to run the hardware test and this is the error message: 4MDT/1/40000003:HDD Does anyone know what that means or what piece of hardware is being problematic?