Thursday, March 8, 2012

Date format: mm/dd/yyyy does not work

I have a date field I am trying to format so it does not show the minutes,sec's. Seems the obvious way to do this would be to put mm/dd/yyyy in the format property. I tried this and the day and year seem to work, but the month is not showing month. rather it appears to be showing minute. Does month use a different letter?

Hello,

Try this instead for your format:

MM/dd/yyyy

Hope this helps.

Jarret

|||

If your goal is only to remove the minutes, seconds, etc. then you could use this:

Left(yourdatefield, 11) which will display Jul 20, 2007

or for the mm/dd/yyyy format use this:

Convert(char(50), yourdatefield, 103) which will display 07/20/2007

|||( Isn't the correct format for MM/DD/YYYY 101 instead of 103? Isn't 103 the format for DD/MM/YYYY? )|||For the format field, you don't put a format mask.

What you want to use for a date like that is just 'd'.

There are some format codes (I don't know what they are based on) that determine how things get presented in various cases. You don't even have to know them. In the Visual Studio interface, right-click the textbox you want to manipulate and view the properties (not the properties tab(?)), view the Format tab, and look for the little button next to the 'Format code' textbox with the ellipsis. It gives you most of the options you are going to need.|||Looks like you're all right. I ended up using MM/dd/yyy. Who knew it would be case sensative. :-p

thanks all
|||

Quite correct Kent. Thanks for catching my typo.

|||

The solution:

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

Helped?

Regards!!!

|||

As you have noticed already, the M must be in capital letters:

M

Represents the month as a number from 1 through 12. A single-digit month is formatted without a leading zero. For more information about using a single format specifier, see Using Single Custom Format Specifiers.

MM

Represents the month as a number from 01 through 12. A single-digit month is formatted with a leading zero.

MMM

Represents the abbreviated name of the month as defined in the current System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames property.

MMMM

Represents the full name of the month as defined in the current System.Globalization.DateTimeFormatInfo.MonthNames property.

small m is used for minute. Read more on books online: http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx.

|||

Hii i have given you choices which one you want you can use that format.

1)This is the expression for the date-monthname-year

Use this and let me know

=Day(Parameters!time.Value)& "th-" & MonthName(Month(Parameters!time.Value))& "-" &

Year(Parameters!time.Value)


2)Expression to get date as 11-Feb-2007 (3 characters of month)

=Day(Fields!Date.Value)& "-" & Left(MonthName(Month(Fields!Date.Value)),3)& "-" &

Year(Fields!Date.Value)


4) Expression to get the date as well as the time with format as h:mmTongue Tieds

="M/dd/yyyy" & " " & "h:mmTongue Tieds tt"

Hope this works fine.

Thanks

Mahasweta

|||

Hii i have given you choices which one you want you can use that format.

1)This is the expression for the date-monthname-year

Use this and let me know

=Day(Parameters!time.Value)& "th-" & MonthName(Month(Parameters!time.Value))& "-" &

Year(Parameters!time.Value)


2)Expression to get date as 11-Feb-2007 (3 characters of month)

=Day(Fields!Date.Value)& "-" & Left(MonthName(Month(Fields!Date.Value)),3)& "-" &

Year(Fields!Date.Value)


4) Expression to get the date as well as the time with format as h:mmTongue Tieds AM/PM

=Format(datefield,"M/dd/yyyy" & " " & "h:mmTongue Tieds tt")

Hope this works fine.

Thanks

Mahasweta

|||

>>Who knew it would be case sensative

It's case-sensitive (M for Month) because "m" stands for "minutes" in the formatting string I think <g>.

Who knew that an accident of English would be so annoying <g>.

>L<

No comments:

Post a Comment