version 2003
PA_SetDateField (tNum; fNum; day; month; year)
| Parameter | Type | Description | |
| tNum | short | Table number of the field to access | |
| fNum | short | Field number of the field to access | |
| day | short | New day of the date field | |
| month | short | New month of the date field | |
| year | short | New year of the date field |
Description
The routine PA_SetDateField sets the value of the date field number fNum of the current record of table number tNum to *day, *month, and *year.
If the field is not a time field, the routine does nothing and sets an error in PA_GetLastError().
Example
Set a field date to the current date under MacOS.
void SetFieldToCurrentDate (short tNum, short fNum)
{
unsigned long secs;
DateTimeRecord dtr;
GetDateTime(&secs);
SecondsToDate(secs, &drp)
PA_SetDateField(tNum, fNum, drp.day, drp.month, drp.year);
}
This can be done using 4D itself, wth the "Date" function (neither error checking here nor localization)
void SetFieldToCurrentDate (short tNum, short fNum)
{
PA_Variable currentDate;
currentDate = PA_ExecuteFunction("Current date", 12);
PA_SetDateField(tNum, fNum, currentDate.day, currentDate.month, currentDate.year);
}
See Also
Error Handling
Use PA_GetLastError to see if an error occurred (eER_InvalidFileNumber, eER_InvalidFieldNumber)