Aug 192013
 

#Example of how to check (validate) the input.
#Read the input and “Check” if it is correct.
#In this case it is checking if the date was input correctly.

read -p "Date (format yyyy-mm-dd): " input
check=$(date +%F)

if [ "$input" == "$check" ]; then
    echo "Right!"
else
    echo "False!"
fi

Source

Jan 142013
 

The example below used two fields; one named “DatePickerField” and the other “TimeSelectBox”. Create a third textbox named DateTimeGroup (or whatever you want) and change the data type to “Date Time”. In the default value box type:

concat(DatePickerField, “T”, TimeSelectBox)

Whenever you choose a date and time the DateTimeGroup box will automatically be populated based on what date and time was chosen. If you want to hide the DateTimeGroup field on the form just set the size to zero and the data it collects can still be used in a SharePoint form library.

Jan 102013
 

Infopath_Display_Date_Datepart

InfopathDateTimeParts

How to use today() and now() functions to get parts of the date to display in a text box.

Go to Controls and insert a text box.
Right-click and select Text box properties
In the Data type select Text (time)
Under Default Value, click the function button fx next to the Value box. (You may be prompted to apply changes. Click OK).
In the formula box enter one of the following formulas according to your needs.

Using the today() function only returns the year month and day. To display the current Year-Month-Day.
Enter: today()

To display only the year.
Enter: substring-before(today(), “-“)

To display only the month number.
Enter: substring-before(substring-after(today(), “-“), “-“)

To display only the year and month.
Enter: concat(substring-before(today(), “-“), ” “, substring-before(substring-after(today(), “-“), “-“))

To display only the month number and day number separated by a dash.
Enter: substring-before(substring-after(today(), “-“), “-“)

To display only the day number.
Enter: substring-after(substring-after(today(), “-“), “-“)

Using the now() function returns the date and time separated by “T”. To display only the time.
Enter: substring-after(now(), “T”)

Notice we are using now() in this formula — now() returns a Date and Time, while today() returns just a date. If you don’t care for military time, set the field to a Time data type and use the format button in the field’s properties to select a different format (the field above is set that way).
To display only the hours.
Enter: substring-before(substring-after(now(), “T”), “:”)

To display only the hours in military time.
Enter: substring-before(substring-after(now(), “T”), “:”) mod 12

Mod operator to the rescue. The remainder of the hour divided by 12 will get us the non-military time afternoon hours:
I think I still need to fix this. I put mod 13 to get it to show 12 at noon. Otherwise, it shows 0 (zero) at noon. The Mod operator is used to display military time.
The remainder of the hour divided by 12 will get us the non-military time afternoon hours. If you don’t care for military time, set the field to a Time data type
and use the format button in the field’s properties to select a different format (the field above is set that way).

To display only the minutes.
Enter: substring-before(substring-after(now(), “:”), “:”)

To display only the seconds.
Enter: substring-after(substring-after(now(), “:”), “:”)