Hi, I have a frustrating error, when trying to format a date. I have tested different solutions, but no luck, so now i turn to you guys. I get this error:
error CS1501: No overload for method 'ToString' takes 1 arguments
In my eyes it looks right, but maybe I am missing something. The "empHire" is a Date Picker.
@{ var members = Member.GetAll; foreach (var item in members) { ...
var hire = item.getProperty("empHire").Value.ToString("d MMMM yyyy"); <p>@hire</p> ... } }
Thank you for the response, but it did not help unfortunatly. I am trying to get a date from a Member, not a page, but I don't know if this makes any difference. I can get it to display the full date and time, but I only need the date.
I have used the .ToString formatting before with luck, but not this time :-/
Format date ToString error
Hi, I have a frustrating error, when trying to format a date. I have tested different solutions, but no luck, so now i turn to you guys. I get this error:
error CS1501: No overload for method 'ToString' takes 1 arguments
In my eyes it looks right, but maybe I am missing something. The "empHire" is a Date Picker.
Thank you :-)
Hi Daniel
Dates are as strange as images, sometimes.
In u6.0.2 Mvc, I have, using your example;
@item.EmpHire.ToString(f") which gives full date-time but also works with ("d MMMM yyyy") from a date-picker.
However am using @CurrentPage as opposed to @Model.Content (think that does make a difference due to the ouput being XML, but not 100% sure)
Hope it helps G
Thank you for the response, but it did not help unfortunatly. I am trying to get a date from a Member, not a page, but I don't know if this makes any difference. I can get it to display the full date and time, but I only need the date.
I have used the .ToString formatting before with luck, but not this time :-/
Daniel
I got it working with this:
:-)
I have a similar problem to this. I don't get an error, my razor saves with no errors using Daniel's method above.
var time = SiteContext.Current.CatalogContext.CurrentProduct.DynamicProperty().CourseDate.Value;
string.Format("{dddd MMMM d yyyy}", @time
however the razor script won't load on the frontend. I've tried various different ways
var time = SiteContext.Current.CatalogContext.CurrentProduct.DynamicProperty();
@time.CourseDate
Displays the date as 04/14/2013 in US form It is a UK site so i need it to display as e.g.
Wednesday 4th April 2013
When i try it as follows:
@time.CourseDate.Value.ToString("dddd MMMM d, YYYY")
@time.CourseDate.Value.FormatDateTime("dddd MMMM d, YYYY")
@time.CourseDate.Value.Format("dddd MMMM d, YYYY")
it saves with no errors but doesn't display.
I've also tried GetProperty("CourseDate") in place of DynamicProperty() with no success.
The CourseDate is using datepicker data type not the Date Time already built in.
Any help would be appreciated. Thank You.
Is there a way to update this so it doesn't show the time?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.