INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Formating a user-defined Date field  (Read 2721 times)

wburkett

  • World Citizen
  • ***
  • Posts: 109
Formating a user-defined Date field
« on: December 24, 2015, 10:16:08 am »

I found some thread that were almost what I was looking for but couldn't find the exact solution.

I've created a user field called "Validated" and assigned it a date data type.  It displays as mm/dd/yyyy  HH:MM xM.   I want to format the date in ISO form as yyyy-mm-dd.  Is there any way to do that?

Bill
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Formating a user-defined Date field
« Reply #1 on: December 24, 2015, 10:25:49 am »

Sure.  Use the FormatDate() function:

http://wiki.jriver.com/index.php/Expression_Language#FormatDate.28.E2.80.A6.29:_Formats_a_date_value_in_a_specified_manner

Seems like a format string of:  yyyy-MM-dd    is what you want.

Brian.
Logged

wburkett

  • World Citizen
  • ***
  • Posts: 109
Re: Formating a user-defined Date field
« Reply #2 on: December 24, 2015, 11:41:11 am »

But where do I put that FormatDate() function?  It doesn't seems like I can use it when I define the library field.

Bill

P.S. You're a great resource, Brian - thanks for sharing your expertise (and sharing it so quickly!)
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Formating a user-defined Date field
« Reply #3 on: December 24, 2015, 11:52:51 am »

where does the data come from?  do you type in a value, into the tag field?  or does it calculate from somewhere else?

Logged

wburkett

  • World Citizen
  • ***
  • Posts: 109
Re: Formating a user-defined Date field
« Reply #4 on: December 24, 2015, 12:03:39 pm »

That is a slightly complicated question, ferday.  Eventually, I'll type the value into the user-defined tag field.  Right now, I'm extracting a text-string date from another field using a regex expression and putting it in that field (using "=regex(etc)").  Which means I could use the FormatDate function on the regex expression.

However: I just tested this by creating a library field with a Date data type: if I type in 2015-12-24 it is converted to 12/24/2015. 

Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Formating a user-defined Date field
« Reply #5 on: December 25, 2015, 12:13:12 pm »

However: I just tested this by creating a library field with a Date data type: if I type in 2015-12-24 it is converted to 12/24/2015.

I'm no expert on date fields, but I think that's just how they display by default.  If you want to display them differently, you can add an expression column and use FormatDate() in that column to show it exactly how you want.  If you're going to use that formatting all the time for display purposes, you can define a *second* field like "Validated Display".  That second field can use Calculated Data as it's definition.  You'd paste your formatdate() expression into Calculated Data, and it would always show you the format you want for the Validated field.

Take a look at the definitions of:  Date (month), Date (day), Date (year), and Date (filename friendly).  They all use calculated data against the Date field, in order to show us all of these other friendly formatted views that all actually derive their values from the Date field.

Brian.
Logged
Pages: [1]   Go Up