Issue with date checking - plsql

In Apex app I've a region called Person on a page. Inside a region there is a masked date picker. I have a task to validate the date of birth. So, the date of birth could not be less 1900 year. In "Conditions" section i'd been trying to write an pl/sql expression:
TRUNC(TO_DATE(:P1002_CONTR_BIRTH_DATE, 'MM-DD-YYYY')) > TO_DATE('01.01.1900', 'MM-DD-YYYY')
but it doesn't work. What am I doing wrong?

You put it to wrong place - "Condition" is used to decide whether an item will (or will not) be rendered on the screen.
Validation should be put into ... well, validation (obviously).
right-click the P1002_CONTR_BIRTH_DATE date picker item
choose "Create Validation"
set its type to "PL/SQL function (returning error text)
use such a code (presuming that you set the date picker format mask to MM-DD-YYYY):
if to_date(:P1002_CONTR_BIRTH_DATE, 'mm-dd-yyyy') < date '1900-01-01' then
return ('Error - can not set it to before 01-01-1900');
end if;
set it to fire when SUBMIT button is pressed
Alternatively (and way simpler) would be to open date picker item's property palette, navigate to its "Minimum date" property and put (for example) -120y in there which will allow dates that are higher than sysdate - 120 years (today, Apex would raise the
Birth date is less than specified minimum date 04-15-1898'
which isn't exactly "1900", but - you can easily calculate it, right? Also, -120y is somewhat more flexible than fixed year 1900.
Now you have two options, pick the one that suits you best.

TO_DATE() method is to convert a string to date, the string format should be the same as format_mask.
TRUNC(TO_DATE(:P1002_CONTR_BIRTH_DATE, 'MM-DD-YYYY')) > TO_DATE('01-01-1900', 'MM-DD-YYYY')
or
TRUNC(TO_DATE(:P1002_CONTR_BIRTH_DATE, 'MM-DD-YYYY')) > TO_DATE('01.01.1900', 'MM.DD.YYYY')
and also make sure :P1002_CONTR_BIRTH_DATE is also the same as format.
For detail

Related

How to set a date for WKInterfaceDate

Can WKInterfaceDate show a date & time different from the current values?
If yes, how can I set a different date?
apple documentation says:
A WKInterfaceDate object is a custom label that displays the current
date or time. Use this object when you want to display date or time
information without further interaction from your WatchKit extension.
At runtime, use the date object to configure the appearance of the
date and time information being displayed.
For different date you can simply create label and set it's text to a String that you create with NSDateFormatter out of some NSDate.

How to remove clock symbol in UTCDatetime Field on form(Dynamics ax)?

I have a UTC date time field on form.
But i need only date to be displayed so i kept display as date.
But i am getting a clock symbol in the field.
Is there any way i can remove that symbol?
I fixed this issue. I changed the Property of "TimeZoneIndicator " property to "Never" on form field level. That fixed the issue.
I assume you mean the calender symbol in the DateTime edit control.
You can disable the hour, minutes and seconds display on the extended data type (TimeHours attribute etc.) or on the DateTime form control, and AX removes the space for the time. However AX still shows the calendar icon, even if you set the LookupButton attribute to Never, unless you also set AllowEdit to No.
What you can do is replace the DateTime control with an edit or display method control, and do the required conversions yourself.
edit date transDate(boolean _set, date _date)
{
TimeOfDay time;
if (_set)
{
time = DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(utc, DateTimeUtil::getUserPreferredTimeZone()));
utc = DateTimeUtil::removeTimeZoneOffset(DateTimeUtil::newDateTime(_date, time), DateTimeUtil::getUserPreferredTimeZone());
}
return DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(utc, DateTimeUtil::getUserPreferredTimeZone()));
}
The utc variable holds the saved date/time value.

Using dates from database column with calendar control

I'm trying to work with the ASP calendar control and (for starters) highlight the specific days on the calendar that matches DueDate in the 'task' table. I know how to highlight a cell using the DayRender event, but how do I do this in accordance to the database table?
Would then also like to be able to click on the highlighted cell and see details of the task associated to that date in some sort of box next to the calendar.
Any pointers on how I can solve this?
Pseudo-code:
Determine your desired date range (probably a certain month)
Read all the tasks that have due dates within that date range (probably need Name and DueDate at least)
In your DayRender handler you check if current day's date exists in the loaded tasks's due dates, if it does, highlight it with the color of your choice
In you SelectionChanged handler you obtain the selected day's date, and look through the loaded list of tasks for any tasks that have that date as their due date, and populate whatever box with those tasks.

Flex - format entry of data as it is entered (date field / dates)?

I am using an mx:DateField in Flex and it works nice with the date picker, but I also need it to be editable, so i set editable="true".
The problem is that now the user can enter anything they want - even though I have a formatString="YYYY-MM-DD" set. The date picker honors this format, but if the user enters in the format MM/DD/YYYY they can - or they can even enter garbage data.
I realize I can set up a data validator to check that it is a valid date and in the appropriate format as per the flex docs, but I was hoping to have something I have seen in other languages where the text field would show something like "0000-00-00" and the user clicks in to the field and it allows them to change only the digits (the zeros) and can not type any alpha characters or add/remove any length.
Any ideas?
Try to use masked text input for that.
Personally, I wouldn't use a DateField. I would create a custom component that has 3 separate TextInputs, one for each year, month and day, and have a DateChooser on the right side if the user wants to pick the date manually.
You'll have to add logic to have the focus bounce from one textinput to the next. You can even make them look like they're in the same component with dashes in between. The user thinks it's just one component, but it's actually a composite component.
Anywho, just my 2 cents. I've done it before with good results.

MS InfoPath: How do you populate a date box by using a function? Mostly a formatting date issue

This might be a simple question. But I am trying to use a rule in an InfoPath field where if a user enters a certain value in a text box, a date box will populate with a certain date.
Example: User enters "Orange" in the Textbox1 field. Datefield1 should populate with 11/30/2010.
The problem is I have no idea how to setup/format the date in the rule box. See picture for details.
InfoPath marks the format as invalid. I've tried 2011-Nov-30, 30-Nov-2011, and a few more. Any ideas?
It has to be the date format yyyy-mm-dd ("2010-01-01"). Alternatively you can use the date function today() if it is always going to be the current date.

Resources