TDateTimePicker delphi get year and month

datetimepicker, delphi

Solution

As TLama said you can use the `DecodeDate` function like this :-

Var
  lDay,
  lMonth,
  lYear : Word;
Begin
  DecodeDate(DateTimePicker2.Date, lDay, lMonth, lYear);
  MyStoredProc.Params[0].AsInteger := lDay;
  MyStoredProc.Params[1].AsInteger := lMonth;
  MyStoredProc.Execute;
End;

Problem

I have a SP built in SQL that has 2 param, one is year and the other one is month. In delphi I added a TDateTimePicker on a frame in order to let the user pick the month and the year. How do I retrie the values of the Year/Day from TDateTimePicker? I've tried `DateTimePicker2.Date;` but this gives me a date in format "xx/xx/xxxx" I want to get the actual Year/month something like ``` int year ; year := DateTimePicker2.Date.Year; ``` Is there any way I can achieve this ?

Original source