Format Calendar Field

I have a field with a displayType of Calendar, how do I format the entered value into yyymmdd? I tried the followign but got a null, globals.startDate is the dataprovider for the field on the form :

formatDate = utils.dateFormat(globals.startDate, “yyyyMMdd”)

just change the format property of this particular element to ‘yyyyMMdd’, note that this pushes the user to enter the date in this format as well.

if you want to enter 12-26-2010 and show 20101226, you should set the format property to ‘yyyyMMdd|MM-dd-yyyy’

hope this helps

Not sure if I’m missing something but

  1. dataProvider is defined as a global variable
  2. the format is defined as dd/MM/yyyy in the form
  3. when user selects a date from the calender it displays it on the field on the form like 'Thu Jul 08 00:00:00 WST 2010 ’ even though the format is defined dd/MM/yyyy
  4. If I have code such as:
    startDate = elements.Start_Date
    Returns the date as:
    CALENDAR[name:Start_Date,x:350,y:6,width:70,height:20,value:Sun Aug 08 00:00:00 WST 2010] {bgcolor:“#ffffff”,editable:true,enabled:true,fgcolor:“#000000”,format:“dd/MM/yyyy”,readOnly:false,toolTipText:null,transparent:false,visible:true}

It appears to me if the dataprovider is a global variable it ignores the format. How do I get startDate to be in a sensible date format.

Yummy:

  1. dataProvider is defined as a global variable
  2. the format is defined as dd/MM/yyyy in the form
  3. when user selects a date from the calender it displays it on the field on the form like 'Thu Jul 08 00:00:00 WST 2010 ’ even though the format is defined dd/MM/yyyy

as for 1, 2 & 3: which datatype does this global variable have? It should be of type ‘DATETIME’.

Yummy:
4. If I have code such as:
startDate = elements.Start_Date
Returns the date as:
CALENDAR[name:Start_Date,x:350,y:6,width:70,height:20,value:Sun Aug 08 00:00:00 WST 2010] {bgcolor:“#ffffff”,editable:true,enabled:true,fgcolor:“#000000”,format:“dd/MM/yyyy”,readOnly:false,toolTipText:null,transparent:false,visible:true}

This is normal. What you actually request is the element object, in this case of the element ‘Start_Date’.

To have the content of a dataprovider, it depends what dataprovider this is. Examples to output this to your console are:

  1. for global var: application.output(globals.myDateVar)
  2. for a dbcolom in a form method: application.output(controller.getDataProviderValue(myDateColumn)
  3. for a dbcolom in a form method: application.output(forms.myNiceForm.controller.getDataProviderValue(myDateColumn)

Note: the element format is just a mask, this doesn’t change the actual value of the dataprovider. As for this the above code will always output in a format like: ‘Sun Aug 08 00:00:00 WST 2010’
If you want to output it in the format you entered, use the function: utils.dateFormat(date, ‘dd/MM/yyyy’)

Hope this helps, if not please post a sample solution so people can take a look at it.