Delphi/Lazarus: Extract Day, Month and Year from DateTime-Format
Question by Guest | Last update on 2023-11-24 | Created on 2015-09-21
I have a date in the format TDateTime, but I need the single segments as integer variables. So, I would like to extract day, month and year from the datetime variable in order to store the values in individual integer variables.
Is there any function available for that or can someone help me how to do that?
Related Topics
MySQL: Group Timestamp Column by Month and Year
Tip | 0 Comments
Delphi/Lazarus: Display current Date and Time
Tip | 0 Comments
PHP: Current Date and Time
Tutorial | 0 Comments
JavaScript: Get current Date and Time
Tutorial | 1 Comment
Delphi/Lazarus: Convert Year, Month and Day to DateTime-Format
Question | 1 Answer
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Delphi as well as Lazarus are coming with a function to do that. The function is called DecodeDate and it can be used in the following way:
First of all, here, we are saving the current date in the variable ADate. However, at the same time, we have declared the variables AYear, AMonth and ADay in which our year, month and day should be written later. For that, we are calling DecodeDate and we are passing all variables to this function. Finally, we are showing the results with ShowMessage().
Last update on 2023-11-24 | Created on 2015-09-23
AYear, AMonth, ADay: word;
(DecodeDate takes word parameters)
2022-10-14 at 02:54
I have corrected it.
Thank you very much.
2022-10-14 at 02:58