Convert multiple string columns to single datetime format

I have 2 string columns
Response1 Response2
20090706 1010
I want to combine these into one date time format column with the result:
2009-07-06 10:10:00.000
How do I achieve this?
.samuel

What does 9:10 AM look like?
Select
cast(
Left(Response1, 4) + '-'
+ substring(Response1,5,2) + '-'
+ right(Response1,2) + ' '
+ right('0'
+ Substring(Response2, 1, len(Response2) - 2), 2)
+ ':' + right(Response2, 2)
as datetime)
from tbl
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

Similar Messages

  • Convert a String to java.sql.Date Format

    Hi,
    I am having a String of containing date in the format 'dd/mm/yyyy' OR 'dd-MMM-YYYY' OR 'mm-dd-yyyy' format. I need to convert the string to java.sql.Date object so that I can perform a query the database for the date field. Can any one suggest me with the code please.
    Regards,
    Smitha

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class TestDateFormat
         public static void main(String args[])
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              System.out.println(sdf.isLenient());
              try
                   Date d1 = sdf.parse("07-11-2001");
                   System.out.println(d1);
                   Date d2 = sdf.parse("07:11:2001");
                   System.out.println(d2);
              catch(ParseException e)
                   System.out.println("Error format, " + e);
    See class DateFormat and SimpleDateFormat for detail.

  • Examples for converting multiple form output to single pdf

    Hi all ,
         I need sample code or examples for converting multiple smart form outputs (more than 1)  to single pdf. Can someone provide that? Reply  ASAP 
    Thanks & Regards,
    Pavan.

    Hi,
    check this:
    [How to merge multiple spools into single PDF file?;
    [Merge multiple PDF Files;
    [https://www.sdn.sap.com/irj/scn/advancedsearch?query=multipleformoutputtosinglepdf++]
    hope u'll get some idea.
    Regards,
    Sneha.

  • Convert Multiple Rows in a single Comma Seprated value

    Is is possible to convert miltiple rows in a single value by concatenating each row value in OBIEE. I think OI had seem a blog post relted to this by I'm not able to to find it again. Basically Here is what I would like to do:
    Customer number Location
    101 IL
    101 NY
    101 PA
    102 TX
    102 CA
    Convert this to
    101 IL, NY, PA
    102 TX,CA
    Can someone please let me know if this is possible and how to make it work.
    Thanks you for the help in advance.

    You can do this by creating a DB function,
    Check this link
    Re: Horizontal value display
    Thanks,
    Vino

  • Convert multiple page PDF to single TIFF doc

    Is it possible to convert multiple page PDF to one TIFF file (with multiple pages).  I also have access to Acrobat 6, 9 and 10.

    Acrobat does not support writing multiple page TIFFs

  • How to convert multiple string values in a single row from nvarchar to int

    suppose I have a table like below.all these values are in nvarchar. How would I find the minimum year from START_DATE??
    PRODUCT_CODE 
    PRODUCT_DESC
    START_DATE
    P00002933
    VITAMINE C
    2005,2000,2011,2001,2002
    P00003087
    BIOFENAC
    2011,2009,2006,2007,2004,2005
    P00000155
    AMOXYPEN
    2006,2007,2008,2009,0000,2001
    P00002325
    SAHHA FARINE
    2008,2003,2002,2001,2009
    P00005666
    AMOXYPEN
    2007,2008,2006,2009,0000,2001

    Create the split function:
    CREATE FUNCTION Split (
    @InputString VARCHAR(8000),
    @Delimiter VARCHAR(50)
    RETURNS @Items TABLE (
    Item VARCHAR(8000)
    AS
    BEGIN
    IF @Delimiter = ' '
    BEGIN
    SET @Delimiter = ','
    SET @InputString = REPLACE(@InputString, ' ', @Delimiter)
    END
    IF (@Delimiter IS NULL OR @Delimiter = '')
    SET @Delimiter = ','
    --INSERT INTO @Items VALUES (@Delimiter) -- Diagnostic
    --INSERT INTO @Items VALUES (@InputString) -- Diagnostic
    DECLARE @Item VARCHAR(8000)
    DECLARE @ItemList VARCHAR(8000)
    DECLARE @DelimIndex INT
    SET @ItemList = @InputString
    SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)
    WHILE (@DelimIndex != 0)
    BEGIN
    SET @Item = SUBSTRING(@ItemList, 0, @DelimIndex)
    INSERT INTO @Items VALUES (@Item)
    -- Set @ItemList = @ItemList minus one less item
    SET @ItemList = SUBSTRING(@ItemList, @DelimIndex+1, LEN(@ItemList)-@DelimIndex)
    SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)
    END -- End WHILE
    IF @Item IS NOT NULL -- At least one delimiter was encountered in @InputString
    BEGIN
    SET @Item = @ItemList
    INSERT INTO @Items VALUES (@Item)
    END
    -- No delimiters were encountered in @InputString, so just return @InputString
    ELSE INSERT INTO @Items VALUES (@InputString)
    RETURN
    END -- End Function
    GO
    Use the below script:
    create table Table1 (Product_Code varchar(50),Product_Desc varchar(10),sStart_date varchar(MAX))
    Insert into Table1 Values('P00002933','VITAMINE C','2005,2000,2011,2001,2002'),
    ('P00003087','BIOFENAC','2011,2009,2006,2007,2004,2005')
    Select Product_Code,Product_Desc ,MIN(Item) Minstart_date
    From Table1 A
    Cross apply Split(A.sStart_date,',') B
    Group by Product_Code,Product_Desc
    Drop table Table1

  • Converting multiple records to a single "Y" on a report?

    Okay, here's one for the experts. I have a table that's a many-to-one relation to each line of detail on my report. For example, a hard drive, Part Number 1234, might be assigned to multiple types of servers, i.e. it was assigned to 6 PE-C servers, 3 DCS servers, and 8 Blade servers. The assignment cross-reference table tells me the server PNs that the drive is assigned to. In the report detail for the hard drive PN, I have several categories, labelled: "PE-C", "DCS", "Blade", "EQL", etc. What I need to do for each line of main report detail (by PN), spin through the XREF file to find the PNs of the servers, then read each server for "Type". If even one server of a given Type (PE-C, etc) is assigned to that hard drive, I need the letter "Y" in the associated column, else a "N".
    So it would look something like:
    Part of the main Report Detail:
    PN. . . . PE-C. . . DCS. . . Blade. . . EQL. . . CML
    1234. . . . .Y. . . . . . Y. . . . . . N. . . . . .N. . . . . .Y
    5678. . . . .N. . . . . . Y. . . . . . Y. . . . . .N. . . . . .Y
    9012. . . . .Y. . . . . . N. . . . . . N. . . . . .Y. . . . . .Y
    depending on which server types are assigned to the HD. There can be several server models under each type assigned to a drive, hence the many-to-one relationship.
    So:
    HD Master Table --> Server Assignment XREF Table -->Server Master Table
    (HD Master: HD PN
    Server Master: Server PN and TYPE
    Server Assignment XREF: HD PN and Server PN)
    I have absolutely NO CLUE how to go about doing this. Any thoughts or ideas would be hugely appreciated.
    Thanks!!

    Interesting. The problem is that the assignment is done through a stand-alone table, the Drive-Server-XREF table. That table only has the PN of the drive and the PN of the servers assigned to it. I would then need to take the PN of each server from that table, use it as a key to lookup the Server data, and pull the Type from that table. Then I would have to determine what the type is, and then assign a "Y" to a field (there would be something like 7 of these Y/N fields, one for each server type), depending on the type. Will your method work in that way?
    So, for example, in the Drive Master table, we have ONE entry for PN 1234:
    1234, somedata1, somedata2, etc
    In the XREF table, we'd have something like:
    1234,DX431 (the PN of the server it's assigned to)
    1234, LT556
    1234, AA221
    1234, DP001
    etc
    Each of those PNs might be a different Type (or some of them would be the same type).
    In the Server Master table, it would be:
    DX431, somedata1, PE-C, somedata2
    LT556, somedata1, Blade, somedata2
    AA221, somedata1, Blade, somedata2
    DP001, somedata1, DCS, somedata2
    so you see, I would have to read across two tables to get what I need.

  • Convert multiple planned orders to single production order

    Dear All !
    In our business, same component is used for manufacturing multiple items. In a sales order multiple items are booked. When we do MRP RUN, system creates multiple planned orders for each line item. We can run only one production order as for every item order quantity becomes very small and we cannot process that lot. To have a sizable lot quantity we need to combine all planned orders into a single production order.
    Can someone please help.

    Govinder,
    Define those components for collective processing. You need to define "2" - for Field Indv/Coll in MRP4 view of those material master and you can have daily/weekly/monthly lotsize defined for those items.
    Regards,
    Prasobh

  • Converting Multiple Excel formulas to Single DAX formula

    Hi,
    I am trying to find a way in powerpivot of combining three 4 validation test columns into one column. The idea is that if the result in test 3 comes up with 'Exclude', I will filter it out of of a measure for a calculation I am doing. I have demonstated
    the calculations I am trying to combine in fields k-n, not sure if anyone can help arrive at this result in one single powerpivot calculation - thanks for looking at this if you can help.
    https://onedrive.live.com/redir?resid=B5D3C9D77C8E76FB!1344&authkey=!ABsaTOjjG2RAYHU&ithint=file%2cxlsx

    Grinch,
    Combining into a single column would be possible but not advised, due to the complexity of the logic you are using. I would recommend - keeping the intermediate columns as shown to get to final result. Then you can right click and choose "Hide from
    Client Tools" for all the intermediate columns so that they are not visible to the user (in the Pivot Table Field List).
    Please vote or mark as answer if you found the response helpful.
    Regards, Avi
    www.powerpivotpro.com
    Wiki:How to ask a Power Pivot Question to get a prompt, accurate and helpful response

  • Multiple strings input to single string output

    Dear all,
    this program is needed for my demo simulation purposes, I'm creating several string inputs to show into a single string output updating (input strings are shown in each line). i attached the picture below, put 2 output strings w/c both doesn't meet my desired result:
    1.) 1st string output - replace the old string w/ new string. what i need is to maintain also the previous strings. the new string will go to the next line.
    2.) 2nd string output - although i got all the strings i needed, it only appears right after the while loop terminates, so i did not see the string inputs updating.
    i'm using LV 8.5.1., any help is appreciated... posting your correct code will be more appreciated.
    thanks in advance...
    Ivel R. | CLAD
    Solved!
    Go to Solution.

    here's my code for anyone to see the actual difference.
    thanks,
    Ivel R. | CLAD
    Attachments:
    update strings.vi ‏14 KB

  • Multiple DB Columns in Single UI Column

    Hi All,
    I have an issue with displaying more than one db columns in one UI column.
    Issue Description*
    1. Presentation List contains the following list of fields
    Report Id
    Reporter Name
    Reporter Business Unit
    Reporter PhoeNo
    Reporter Lead
    Lead Phone
    Portfolio
    etc...
    2. I have to display the above column in the UI like
    Id                 |     Reporter Detail                                                                                                                |         Lead                                      | Portfolio
    Report Id | Reporter Name   Reporter Business Unit \n  Reporter PhoeNo | Reporter Lead   Lead Phone | Portfolio
    Please provide the me the steps to do

    @christian. With the balise
    Put it before and after your code and it will not be parsed.                                                                                                                                                                                                                       

  • Convert multiple row field to single line

    Firstly: Apologies I am not a developer and am learning how to use crystal by error and hardwork.. so I'm a little slow on the lingo and the uptake.
    I am creating a report that has under "details" a field {jobTests.testTypeName} this currently finds all tests associated with the job and lists them one under another. i.e
    (Job blah blah) Test1
                          Test3
                          Test7
                          Test9
    Job info (blah blah)  is displayed by a different field under the details tab, it is not associated.
    Then it repeats with the next job until all jobs under a PO are completed, then it moves to the next PO and continues
    To save space I need to list the Tests beside one another i.e Test1, Test 3, Test7, Test9.
    I haven't been able to work out how to do this at all.
    OR
    If it is possible can anyone tell me how to take the list of Tests that are output and enter them under an IF THEN statement...
    I can choose one TEST and rename (as shown below) but I need to be able to choose a group of specific tests i.e   If Test1 + Test3 + Test7 + Test9 Then display "Group 1"
    If {jobTests.testTypeName} = "TEST1" Then
       "T1"
    Else
       {jobTests.testTypeName}
    Thanks to anyone who can help. I hope my question makes sense.
    Edited by: Kathryn Todd on Nov 11, 2008 4:01 PM fixed typo

    Hi Kathryn,
    If you haven't done so already, create a group on the Job. 
    In the Group Header for Job, create a formula like:
    WhilePrintingRecords;
    StringVar Tests := "";
    In the Detail section, create a formula like:
    WhilePrintingRecords;
    StringVar Tests;
    Tests := Tests & {jobTests.testTypeName} & " ";
    Create a third formula in the Group Footer for the Job like:
    WhilePrintingRecords;
    StringVar Tests;
    Here's what's happening.  The first formula is in the Group Header to define and initialize the variable called Tests.  The variable will be reset for each new Job otherwise you'd eventually get all the tests for all the jobs. 
    The second formula will create your string. 
    The last formula will display the string for each test. 
    Good luck,
    Brian

  • Convert multiple rows into a single row

    Hi friends..
    I have a table with the following information
    SQL> select * from tsting;
             A          B          C D         E
            10
                       10
                                  10
                                     29-MAY-09
                                               TESTBut I need the following result..
           A          B          C D         E
          10           10         10 29-MAY-09 TEST

    Hello,
    Try:
    WITH test_data AS (
    SELECT 10 A, NULL B, NULL C, NULL D, NULL E FROM DUAL UNION ALL
    SELECT NULL A, 10 B, NULL C, NULL D, NULL E FROM DUAL UNION ALL
    SELECT NULL A, NULL B, 10 C, NULL D, NULL E FROM DUAL UNION ALL
    SELECT NULL A, NULL B, NULL C, TO_DATE('29-MAY-09','DD-MON-YY')  D, NULL E FROM DUAL UNION ALL
    SELECT NULL A, NULL B, NULL C, NULL D, 'TEST' E FROM DUAL)
    -- end test data
    SELECT MAX(A) A, MAX(B) B, MAX(C) C, MAX(D) D, MAX(E) E
      FROM test_data;
             A          B          C D         E
            10         10         10 29-MAY-09 TEST

  • SQL Query to convert multiple rows to a single row output

    I have the following sql query;
    SELECT B.ClientID,
    B.BillNo, B.[BillDate],
    B.CurrencyCode,
    B.BAmount
    FROM tblCompanyDetails CD
    CROSS
    APPLY (
    SELECT TOP 5 B1.ClientID,
     B1.[BillNumber],
    B1.[BillDate], B1.[CurrencyCode] AS CCY,
     B1.[BillAmount]
    FROM tblBills B1
    WHERE ROUND(B1.[BillAmount],2)<>0
    AND B1.ClientID=CD.CompanyID
    AS B
    WHERE CD.ContactId=235405
    ORDER
    BY B.ClientID,B.BillNo
    DESC
    This gives me the following row output;
    ClientID
    BillNo
    BillDate
    CurrencyCode
    BAmount
    94466
    425616
    2015-04-07
    GBP
    5000
    94466
    424517
    2015-01-15
    GBP
    6000
    94466
    424455
    2014-10-15
    GBP
    4000
    However, I would like the ouput to appear like this;
    ClientID
    BillNo1
    BillDate
    CCY
    BAmount
    BillNo2
    BillDate
    CCY
    BAmount
    BillNo3
    BillDate
    CCY
    BAmount
    94466
     425616
     2015-04-07
     GBP
     5000
     424517
     2015-01-15
     GBP
     6000
     424455
     2014-10-15
     GBP
    4000 

    I have tried to create a sample based on your question
    CREATE TABLE MyTable
    ClientID INT ,
    BillNo INT,
    BillDate DATE,
    CurrencyCode varchar(5),
    BAmount INT
    INSERT INTO MyTable
    VALUES (94466,425616,'2015-04-07','GBP',5000),
    (94466,424517,'2015-01-15','GBP',6000),
    (94466,424455,'2014-10-15','GBP',4000)
    Then I have used another table to put ranking in that, you can actually tweak your statement to include rank also
    CREATE TABLE RowTable
    ClientID INT ,
    BillNo INT,
    BillDate DATE,
    CurrencyCode varchar(5),
    BAmount INT,
    Ranking INT
    INSERT INTO RowTable
    SELECT * , ROW_NUMBER() OVER (ORDER BY ClientID) as row
    FROM MyTable
    Once your data is ready then execute below dynamic query
    DECLARE @cols AS NVARCHAR(MAX),
    @query AS NVARCHAR(MAX)
    select @cols = STUFF((SELECT ',' + QUOTENAME(col+cast(Ranking as varchar(10)))
    from RowTable
    cross apply
    select 'BillNo', 1 union all
    select 'BillDate', 2 union all
    select 'CurrencyCode', 3 union all
    select 'BAmount' , 4
    ) c (col, so)
    group by col, so, Ranking
    order by Ranking, so
    FOR XML PATH(''), TYPE
    ).value('.', 'NVARCHAR(MAX)')
    ,1,1,'')
    set @query = 'SELECT ClientId,' + @cols + '
    from
    select clientid, col+cast(Ranking as varchar(10)) col, value
    from RowTable
    cross apply
    SELECT ''BillNo'', cast(BillNo as varchar(20)) union all
    SELECT ''BillDate'', cast(BillDate as varchar(20)) union all
    SELECT ''CurrencyCode'', CurrencyCode union all
    SELECT ''BAmount'', CAST(BAmount as varchar(10))
    ) c (col, value)
    ) x
    pivot
    max(value)
    for col in (' + @cols + ')
    ) p '
    execute sp_executesql @query;
    Output: 
    Hope this will help. 

  • Convert a String to Decimal Format in European format

    Hi Experts,
    I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format
    User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00
    String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
    Locale mylocale  = Locale.GERMAN;
    String pattern="###.###,00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(Str1);
    wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);
    When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"
    Please let me know, how to convert a String to Quantity in European format
    Thanks & Regards,
    Palani

    Hello!
    Try to change your pattern to this one 
    Locale mylocale  = Locale.GERMAN;
    String pattern = "#,#00.00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(1111111.222);
    Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
    Thanks, Mikhail

Maybe you are looking for