Displaying nvarchar datatype column having a date value

  • Please help me in displaying a nvarchar datatype column called 'txtValue' having date value in the format '15 Jul 2013' in my SSRS report

  • Any reason you're storing a number (a date) in an NVARCHAR field? If you can fix that, then the problem would go away.

    Did you try casting the value as a date in SSRS or creating a calculated value that does it? (since there are a lot of predefined formats that you can use if you do that)...

  • u can cast / convert the data type of column in your source query or Stored Procedures.

    Well, why are u using nvarchar to store a date.? 🙂

  • All of the date manipulation bits you should ever need: https://www.simple-talk.com/sql/learn-sql-server/robyn-pages-sql-server-datetime-workbench/

  • Thanks everybody.

    I fixed the issue, this way using SSRS report expression

    Format(CDate(Fields!DateOfReportManagement.Value), "dd-MMM-yyyy")

  • Great, now change the data type to the correct data type in the table. And if possible, change the column name to something much more descriptive. One should be able to look at the column name, and know exactly what is stored in that column.

    Andrew SQLDBA

  • AndrewSQLDBA (10/1/2013)


    Great, now change the data type to the correct data type in the table. And if possible, change the column name to something much more descriptive. One should be able to look at the column name, and know exactly what is stored in that column.

    Andrew, you hit the nail on the head there. You know, I've seen more questions posted on handling dates stored in string fields that it makes my head spin. The data type ensures that the data is stored properly and is independent of format or presentation.

  • Exactly Correct Ed

    And it takes so much more time, code and processing power to convert all that string garbage into what you really want, if you only use the correct data types. Not only for dates, for everything. I Never use International data types, unless I am storing International characters, and that is Very rare that I design a database for that purpose. But yet I see people using nvarchar() All the time. That is a total waste of space unless it is truly needed.

    Andrew SQLDBA

  • SELECT CAST(N'15 Jul 2013' AS DATE)


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

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

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