Friday, February 24, 2012

Format date and number!

Dear Friens,

I'm having some problem to format my date and number fields!! :-(

In my column I have a date in the format 2007-05-28 00:00:00, and I want it to 28-05-2007.

And the field number I have in the format 28377497636.4987 and I need or 28.377.497.636,4987

or € 28.377.497.636.4987.

Could you help me?

Thanks!!

Hi,

for formating the date field:

use

=format(field!t1.value,"dd-MM-yyyy")

this will give desired output.

for number field,

i feel if u select User!Languages from global for the report language properties and then for the particular textbox or cell,right click->format properties->currency and select given option,the format you want will be taken care off.

hope this works...

Regards,
somiya

|||

Hi Pedro,

There can be many different ways it can be achieved you can try if it fits the following way:

Code Snippet

DateTime objDateTime;

DateTime.TryParse("2007-05-28 00:00:00", out objDateTime );

string strMyDate = objDateTime.Day.ToString() + "-" + objDateTime.Month.ToString() + "-" + objDateTime.Year.ToString();

MessageBox.Show(strMyDate);

string strMyCurrency;

double dValue = 28377497636.4987;

strMyCurrency = String.Format("{0:€ #,###.##;€ -#,###.##;€;}", dValue);

//In above string you can replace the commas with dots or vice versa as whatever format you want

MessageBox.Show(strMyCurrency);

Thanks,

Nitin

|||

Where I write the statment? In expression field?!

I dont think so! :-(

Regards!

|||

It works for the date if I write inside the expression of the date field:

=day(Fields!Dia.Value)& "-" & month(Fields!Dia.Value)& "-" & year(Fields!Dia.Value)

But the date comes in the format 30-5-2007, and I want in 30-05-2007...

|||

you can try the following in the expression of the date field:
=Format(Fields!Dia.Value,"dd-MM-yyyy")
this will format it to 30-05-2007.

Regards,
Somiya.
|||

Somiya,

I already tried it, but does not work...

Returns me dd-MM-yyyy in spite of the date...

I used:

=Format(Fields!Dia.Value,"dd-MM-yyyy")

|||Try using

Code Snippet

=Format(CDate(Fields!Dia.Value),"dd-MM-yyyy")

Also verify that your date field is not null

|||um,,, how about using formatDate with the regional settings set correctly?|||

If your date field is coming as varchar and has null values from the database then you can use the following expression in the textbox.

=iif(Fields!HIREDATE.Value = nothing,"",format(cdate(Fields!HIREDATE.Value),"dd-MM-yyyy"))

Here HIREDATE will be your corresponding date field.

No comments:

Post a Comment