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 :
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
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.
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:
for global var: application.output(globals.myDateVar)
for a dbcolom in a form method: application.output(controller.getDataProviderValue(myDateColumn)
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.