• Help Needed
  • How can I format a Date in a HTML custom layout template?

<div class="aw-data-item">
<b>{Subject}</b> by {sc_CreatedBy} on {CreatedOn}
</div>

The date displays 27-09-2018
but that format isn't used in any of my Date attributes.

Isn't there a way to format this using an @ sign or something.
Like this... {CreatedOn,@MM/dd/yy}

Jaymer wrote

<div class="aw-data-item">
<b>{Subject}</b> by {sc_CreatedBy} on {CreatedOn}
</div>

The date displays 27-09-2018
but that format isn't used in any of my Date attributes.

Isn't there a way to format this using an @ sign or something.
Like this... {CreatedOn,@MM/dd/yy}

When you are using HTML on forms it is <<BO.CreatedOn, MM/dd/yy>> no @ sign (though I prefer the Dutch name for it: "monkey tail")

still need a solution.
this is in a custom layout template where << >> are NOT used
thx
jaymer...

why not just create a new computed field (text) that has a rule to format the date the way you want it displayed and use that field on the form.

Bruce

Silly question, Jaymer, but did you put M/dd/yy in the Format section of the Date attribute you are trying to display in the query?

Good questions and suggestions guys, but you're missing the boat.

See the pics below and you'll see where this is used.
Thanks!

Definition of the Field:
Screen Shot 2018-09-29 at 9.04.37 PM.png

Its for a Combo Box on a form, to pretty the dropdown options:
Screen Shot 2018-09-29 at 9.03.02 PM.png

Result looks like this:
Screen Shot 2018-09-29 at 9.01.45 PM.png

This is from a Custom Query, and it CORRECTLY used a Format associated with the Attribute to format the Date.
Must be a bug in the Custom List code.

THIS: Event Date: <b>{TransDate, @MM/dd/yy}</b></br> did not work. Output was the same.
THIS: Event Date: <b>{TransDate,@MM/dd/yy}</b></br> threw an error for unknown field when trying to Save template.

But the Question is still valid:
In this Custom Query, how would you format the Timestamp field to ONLY show the Date and NOT the time?

Custom Query snippet:

<div class="aw-data-item">
Event Date: <b>{TransDate}</b></br>
Type: <b>{TransType}</b></br>
Descr:: <b>{Descr}</b></br>
Message: <b></b></br>
Opened: <b>{xOpened}</b> Clicked: <b>{xClicked}</b> Bounced: <b>{xBounce}</b></br>
</div>

Screen Shot 2018-09-29 at 11.11.59 PM.png

This is what you can do:

var d = kendo.parseDate (data["NameOfYourDateOrTimestampAttribute"], "MM/dd/yyyy HH:mm");

var s = kendo.toString (d, "MMM dd yyyy");

<span>
#= s #
</span>

a month later

thanks - this is a great help

6 years later