locked
Another date Param issue RRS feed

  • Question

  • I have two date parameters startdate and enddate

    the expresion for start date is

    =CDate("1/" & month(today())& "/" & year(today()))

     

    This gives me the 1st of the month, the second is

     

    =CDate(day(today())& "/" & month(today())& "/" & year(today()))

     This gives me todays date.

     

    When I run this is preview it all looks fine but when i publish it the default dates in the param boxes are;

     

    StartDate: 01/06/2008 (which is good!)

    EndDate: 23/06/2008 00:00:00 (which is not so good!)

    It looks a bit messy. Can I change something on my expression for EndDate?

     

    The Report language is English (UK)

    Monday, June 23, 2008 9:56 AM

Answers

  •  ICW wrote:

    I am using BIDS to create this. Is this the thing I need to check if it is up to date? How do I do that?

     

    Can you run this script and post results:

     

    Code Snippet

    USE master;

    GO

     

    SELECT

    'Microsoft SQL Server ' +

    convert(varchar, SERVERPROPERTY('ProductVersion') ) + ' #-- ' +

    convert(varchar, SERVERPROPERTY('ProductLevel') ) + ' #-- ' +

    convert(varchar, SERVERPROPERTY('Edition') ) + ' #-- ' +

    convert(varchar, SERVERPROPERTY('EngineEdition') ), @@VERSION ;

    GO

    EXEC sp_dbcmptlevel YourDB

     

    GO

     

     

    Wednesday, June 25, 2008 6:44 AM

All replies

  • Hi

     

     

    For EndDate you can try using this expression

     

    =FormatDateTime(now(),dateformat.shortdate)

     

    Let me know if this works

     

    Thanks

     

    Regards

    smitha

    Monday, June 23, 2008 10:05 AM
    Answerer
  •  

      "Shortdate" is an "unrecognized identifier"

     

    and

     

    =FormatDateTime(now(), 2) just doesn't work it says "doesn't have the expected type"

     

    Any other ideas?

    Monday, June 23, 2008 11:15 AM
  • Try this
    =Format(Today(),"dd/MM/yyyy")


    Monday, June 23, 2008 12:04 PM
  •  

    Microsoft SQL Server 9.00.3054.00 --$ SP2 --$ Standard Edition --$ 2 Microsoft SQL Server 2005 - 9.00.3054.00 (Intel X86)   Mar 23 2007 16:28:52   Copyright (c) 1988-2005 Microsoft Corporation  Standard Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
    Monday, June 23, 2008 12:22 PM
  •  Sandeep Babbar wrote:
    Try this
    =Format(Today(),"dd/MM/yyyy")


    This was another "not expected type" unfortunately. very puzzling

    Monday, June 23, 2008 12:23 PM
  • Just curious, why can't you just put =today() in the default values for your @EndDate parameter? It is set as datetime, right?

     

    Monday, June 23, 2008 7:17 PM
    Answerer
  • Shortdate is unrecognized by the expression editor.. However this does work when you execute..

    Give it a try Smile

    =FormatDateTime(now(),dateformat.shortdate)

     

    Tuesday, June 24, 2008 3:25 PM
    Answerer
  • =FormatDateTime(now(),dateformat.shortdate) ... still unrecognised.

     

    I'm thinking this is a bug, almost anything I put in the default expr for the enddate parameter either throws an error or gives me all the zeros at the end. I even ditched and recreated the EndDate parameter

     

    I am using BIDS to create this. Is this the thing I need to check if it is up to date? How do I do that?

    Wednesday, June 25, 2008 5:16 AM
  • Dumb question time...

    you do have them both set as datetime and not string?
    Wednesday, June 25, 2008 6:31 AM
  •  ICW wrote:

    I am using BIDS to create this. Is this the thing I need to check if it is up to date? How do I do that?

     

    Can you run this script and post results:

     

    Code Snippet

    USE master;

    GO

     

    SELECT

    'Microsoft SQL Server ' +

    convert(varchar, SERVERPROPERTY('ProductVersion') ) + ' #-- ' +

    convert(varchar, SERVERPROPERTY('ProductLevel') ) + ' #-- ' +

    convert(varchar, SERVERPROPERTY('Edition') ) + ' #-- ' +

    convert(varchar, SERVERPROPERTY('EngineEdition') ), @@VERSION ;

    GO

    EXEC sp_dbcmptlevel YourDB

     

    GO

     

     

    Wednesday, June 25, 2008 6:44 AM
  • Create a new dataset
    SELECT
    CONVERT(CHAR(10),GETDATE(),103) as defaultdate
    Go to report parameter box
    Select the dataset name and defalutldate
    and get the job done

    Wednesday, June 25, 2008 6:39 PM
  • Use this
    select cast(cast(dateadd(day,-0,getdate()) as varchar(12)) as datetime) as DateFrom
    Monday, July 7, 2008 3:37 PM