April 16, 2010 at 5:58 am
Hi
All,
I have declared a field CDATE as VARCHAR(15) in a temporary table. And I m displaying the value in that field in a report.
It is in mm/dd/yyyy format. Its datatype is varchar
Can I change that format to dd/mm/yyyy before displaying it in the SSRS.
Please post the answers.
Thank you
April 16, 2010 at 6:16 am
first, you should never store dates as any datatype except datetime.
fix it now so you don't have the same issue in the future; if it's stored as a date, you can convert it to any string format you want, or let the presentation layer do it as well.
that avoids this issue right up front.
if you can't convert the column, then
i would add a calculated column to your table.
then i'd convert the varchar to date and back to the desired format, or just do it inline in your select/update statement.
declare @val varchar(30)
set @val='04/16/2010'
select
convert(datetime,@val), --datetime,
convert(varchar(30),convert(datetime,@val),103) --103 format='16/04/2010'
Lowell
April 16, 2010 at 6:20 am
hi,
Please look into the following statements....
SELECT CONVERT(VARCHAR(12),GETDATE(),103) ---16/04/2010
SELECT CONVERT(VARCHAR(12),GETDATE(),101) ---04/16/2010
Convert the VARCHAR datatype to DATETIME and use 103 as in the above statements in the backend SP..
Sasidhar Chowdary
April 16, 2010 at 7:34 am
Thank you Lowell your logic really worked. Thank you so much. I was badly in need of this answer man.
Thank u again.
Sachin
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply