dataset ?

  • Hi all,

    My query has data that drives off of @reportstart @reportend but for the same paramerters the dataset in the report runs blank, therefore available values are empty. What could be the reason.

    thanks.

  • Not sure. We can't see what you see. Really need more information to give you an real answer.

  • SQL_path (5/9/2012)


    Hi all,

    My query has data that drives off of @reportstart @reportend but for the same paramerters the dataset in the report runs blank, therefore available values are empty. What could be the reason.

    thanks.

    wild guesses: make sure ALL fields and paramters are datetimes; if any of them are varchars, your statement might return no rows.

    make sure your parameters actually have values whn they hit the query; if they were null, you'd get no data either.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you all. That was the case,

    Now I am struggling with bad data , would appreciate your help. I want to convert following data in datetime hhmmss format Here is what the data looks like

    I have following data as

    create table #123

    (dates varchar(25) null)

    INSERT INTO #123 (dates)

    SELECT '1/4/1996'

    UNION ALL

    SELECT ' 10/11/1996'

    UNION ALL

    SELECT '1/1/08'

    UNION ALL

    SELECT '12/16/11'

    UNION ALL

    SELECT '5-02-11'

    union all

    SELECT '05-10-11'

    select * from #123

    ----------I tried to convert as following but getting an error---Conversion failed when converting date and/or time from character string.

    select convert (datetime,ltrim(rtrim(dates)), 101) from #123

    drop table #123

    thanks

  • The following works on my pc.

    create table #123

    (dates varchar(25) null);

    go

    INSERT INTO #123 (dates)

    SELECT '1/4/1996'

    UNION ALL

    SELECT ' 10/11/1996'

    UNION ALL

    SELECT '1/1/08'

    UNION ALL

    SELECT '12/16/11'

    UNION ALL

    SELECT '5-02-11'

    union all

    SELECT '05-10-11';

    select * from #123 ;

    ----------I tried to convert as following but getting an error---Conversion failed when converting date and/or time from character string.

    select convert (datetime,ltrim(rtrim(dates))) from #123;

    go

    drop table #123;

    go

  • i see it does fail if your DATEFORAMT is DMY and not MDY: i get the same error you got when i explicitly set my dateformat:

    (/12//16/11 causes the error: no month 16 exists)

    SET DATEFORMAT DMY

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • thank you,

    that worked for the data I posted, I guess I still have some bad data, as I still get the same error any tips on how to locate that in some 4000 number of rows.

    i tried searching as -

    where rtrim( ltrim(dates)) like '%-%' or dates like '%/%'

    thanks

  • SQL_path (5/10/2012)


    thank you,

    that worked for the data I posted, I guess I still have some bad data, as I still get the same error any tips on how to locate that in some 4000 number of rows.

    i tried searching as -

    where rtrim( ltrim(dates)) like '%-%' or dates like '%/%'

    thanks

    Not off hand. That is one of the problems with storing dates as character strings.

    Oh, wait. Try running a query that returns rows where isdate([DateStringColumn]) = 0. It should find some of them.

  • Thank you so much..it worked. 🙂

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply