| |

VerySource

 Forgot password?
 Register
Search
View: 881|Reply: 2

Ask a master datetimepicker

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-8 10:00:02
| Show all posts |Read mode
In a management system, I use two datetimepicker controls to indicate the starting year and month and ending year and month of the rent paid. The style is set to up and down arrow, and the format is set to display only the year and month, because there is no 30 in February. And on the 31st, when the current date is 30 or 31, an error occurs when the month is changed to 2. A friend helped me solve this problem in the post, that is, first set datetimepicker2.date:=startofthemonth(now), now Encountered a new problem: when entering the time into the database, you need to set the date of datetimepicker2 to the last day of the month. Otherwise, when the query condition is time, the query will be one month less. I tried to write such code in the onExit event of the datetimepicker: datetimepicker2.date:=endofthemonth(datetimepicker2.date), but it didn't work at all. Which hero can help me solve it.
Reply

Use magic Report

0

Threads

34

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-12-8 10:15:01
| Show all posts
Why do you have to enter it manually? How good is automatic? The dateutils unit and sysutils unit have many functions for calculation.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-8 13:00:01
| Show all posts
You can change the format property in the DateTimePicker control to'yyyy-MM', and note that the month should be capitalized so that the year and month are selected.

Use the following statement when warehousing, so that the returned string is the date of the last day of each month
FormatDateTime('yyyy-mm',DateTimePicker1.DateTime)+'-'+IntToStr(DaysInMonth(DateTimePicker1.DateTime))
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list