TOPIC: Date with year and month only
#274
Date with year and month only 4 Years, 1 Month ago
Hello,
Try this -
Code:


Controller
 {
 Controls:(Params
Params: (Horz
(Center
(Vert (ChooseYearMonth name:'yearmonth') )))
QueryFormat
{
Query()
{
Inspect(Date(.Params.yearmonth))
return 'tables'
}
}
)
}



The Inspect returns 20200612 when 2006 December is selected. If Date() is removed 200612 is returned. Could not find where the error is. A minor mistake in ChooseYearMonthControl which carries status: "a four digit year and month e.g.......
A related point - Date("2006Dec") returns false. Shouldn't it give #20061201? Similarly if Date is called with just a month's name it should not return false, but should it append current year and either current day / first day?

ajith
 
 
#282
Re:Date with year and month only 4 Years, 1 Month ago
Hi Ajith,

Seems to work as it should to me:
ChooseYearMonth returns the string '200612', it is interpreted as 'yyMMdd' by Date(), so #20200612.
If you append '01' to the string, you'll get what you expect.

Date() requires at least the month and day given. If the year is ommitted it will assume the closest year to the current date. I would prefer that all three parameters always have to be supplied: w/o the year I would expect the year to be the present one. Leaving out any of these parameters doesn't seem much usefull to me, because you can add them yourself to strings missing them and control/know what the result will be.

Jos
 
 
#283
Re:Date with year and month only 4 Years, 1 Month ago
Hi,
When I use ChooseMonthYear, I want to use the return value as Date(value), and I believe others also use it the same way at least occassionally. If this does not give the expected result, (i.e. if Date expects a day portion as well) shouldn't the value returned by ChooseMonthYear be modified to return just 4 digits (thopugh Date doesn't manage 4 digits at present), or append 01 automatically?
ajith
 
 
#291
Re:Date with year and month only 4 Years, 1 Month ago
Hi Ajith,

ChooseMonthYear returns the year as four digits and the month as two, so it's always a fixed format. Returning 4 digits would mean you would leave off the century part?
We could discuss endlessly what ChooseMonthYear should return, but in the past this is choosen and it's one of the options.
You could redefine ChooseMonthYear to return a date by adding:

Get()
{
return Date(.Field.Get() $ '01')
}

This would return false if no selection is made and you would also have to change .Get() in Valid?() to .Field.Get().

Jos
 
 
#296
Re:Date with year and month only 4 Years ago
Hello,
Thanks, I will try changing the Get() method.
ajith