Creating a date out of a month, day and year
QUESTION: I have a date stored as 3 numeric fields in my database. The field "MM" holds the month, "DD" holds the day and "YYYY" holds the year. Can I convert these to a single date in ProVal? Also, I want to create a date that is the first day of the calendar year of hire, but the hire date, not the hire year, is in the data. Can I do that?
ANSWER: Yes to both.
You can convert a year, month and day into a single date: use Define Field by Expression to create a new field, e.g., DATE, with the expression: 1/1/1900 #DATEPLUS { [(YYYY-1900)*1y] + [(DD-1)*1d] + [(MM-1)*1m] }.
You can also extract the year, month and/or day from a date and then use the extracted values to create a new date. So, to create a date containing the first day of the calendar year of hire, if the hire date field is named HIREDATE, enter #YEAR HIREDATE in place of YYYY above, and drop the second and third terms (which advance the month and day past January 1). Similarly, to create a date using a month or day embedded in a date (e.g., DATE), enter #MONTH DATE or #DAY DATE in place of MM or DD, respectively.