Practice 50 C# Date Time Programming Questions
Q1. Write a C# program to display the current date and time.
Output: Current Date and Time: 01/03/2025 10:45:30
Q2. Write a C# program to display the current date in dd/MM/yyyy format.
Output: Current Date: 03/01/2025
Q3. Write a C# program to display the current time in HH:mm:ss format.
Output: Current Time: 10:45:30
Q4. Write a C# program to display the current day of the week.
Output: Day of the Week: Friday
Q5. Write a C# program to calculate the number of days between two dates.
Input: Start Date: 01/01/2025, End Date: 03/01/2025
Output: Number of Days: 2
Q6. Write a C# program to add 10 days to the current date.
Output: New Date: 13/01/2025
Q7. Write a C# program to subtract 5 days from the current date.
Output: New Date: 29/12/2024
Q8. Write a C# program to find the difference in months between two dates.
Input: Start Date: 01/01/2025, End Date: 01/04/2025
Output: Difference in Months: 3
Q9. Write a C# program to display the current date and time in yyyy-MM-dd HH:mm:ss format.
Output: 2025-01-03 10:45:30
Q10. Write a C# program to get the current year.
Output: Current Year: 2025
Q11. Write a C# program to get the current month.
Output: Current Month: 1
Q12. Write a C# program to get the current day of the month.
Output: Day of the Month: 3
Q13. Write a C# program to display the last day of the current month.
Output: Last Day of the Month: 31/01/2025
Q14. Write a C# program to get the current time in hh:mm:ss tt format.
Output: Current Time: 10:45:30 AM
Q15. Write a C# program to calculate the age of a person based on their birthdate.
Input: Birth Date: 15/06/1995
Output: Age: 29
Q16. Write a C# program to find the day of the week for a given date.
Input: Date: 03/01/2025
Output: Day: Friday
Q17. Write a C# program to display the number of days in the current month.
Output: Days in Current Month: 31
Q18. Write a C# program to get the current time and display it in 12-hour format with AM/PM.
Output: Current Time: 10:45:30 AM
Q19. Write a C# program to display the date 30 days from the current date.
Output: New Date: 02/02/2025
Q20. Write a C# program to check whether the current year is a leap year.
Output: Is Leap Year: False
Q21. Write a C# program to check if a given year is a leap year.
Input: Year: 2024
Output: Leap Year: True
Q22. Write a C# program to find the first day of the current month.
Output: First Day of the Month: 01/01/2025
Q23. Write a C# program to find the number of days in a given year.
Input: Year: 2025
Output: Number of Days: 365
Q24. Write a C# program to add 1 year to the current date.
Output: New Date: 03/01/2026
Q25. Write a C# program to add 1 month to the current date.
Output: New Date: 03/02/2025
Q26. Write a C# program to add 1 day to the current date.
Output: New Date: 04/01/2025
Q27. Write a C# program to subtract 1 year from the current date.
Output: New Date: 03/01/2024
Q28. Write a C# program to subtract 1 month from the current date.
Output: New Date: 03/12/2024
Q29. Write a C# program to find the current date and time in UTC.
Output: Current Date and Time in UTC: 2025-01-03 15:45:30
Q30. Write a C# program to convert a given date string to DateTime format.
Input: Date String: "03/01/2025"
Output: DateTime: 03/01/2025 00:00:00
Q31. Write a C# program to convert the current date into a string in yyyy/MM/dd format.
Output: Date: 2025/01/03
Q32. Write a C# program to find the number of seconds from a given date to the current date.
Input: Date: 01/01/2025
Output: Seconds: 2592000
Q33. Write a C# program to check if a given date is valid.
Input: Date: 31/02/2025
Output: Invalid Date
Q34. Write a C# program to calculate the difference between two dates in hours.
Input: Start Date: 01/01/2025 10:00:00, End Date: 01/01/2025 15:00:00
Output: Difference in Hours: 5
Q35. Write a C# program to calculate the difference between two dates in minutes.
Input: Start Date: 01/01/2025 10:00:00, End Date: 01/01/2025 10:45:00
Output: Difference in Minutes: 45
Q36. Write a C# program to format a date to yyyyMMdd format.
Input: Date: 03/01/2025
Output: Formatted Date: 20250103
Q37. Write a C# program to display the date and time 10 hours from the current time.
Output: New Date and Time: 03/01/2025 20:45:30
Q38. Write a C# program to display the date 10 days before the current date.
Output: New Date: 24/12/2024
Q39. Write a C# program to display the current time in HH:mm:ss format.
Output: Current Time: 10:45:30
Q40. Write a C# program to convert a DateTime object to a Unix timestamp.
Input: DateTime: 01/01/2025
Output: Unix Timestamp: 1735670400
Q41. Write a C# program to calculate the number of weeks between two dates.
Input: Start Date: 01/01/2025, End Date: 01/04/2025
Output: Weeks: 13
Q42. Write a C# program to check if a given date is in the future.
Input: Date: 03/01/2026
Output: Future Date
Q43. Write a C# program to check if a given date is in the past.
Input: Date: 01/01/2024
Output: Past Date
Q44. Write a C# program to calculate the difference in years between two dates.
Input: Start Date: 01/01/2020, End Date: 01/01/2025
Output: Difference in Years: 5
Q45. Write a C# program to find the date 6 months from today.
Output: New Date: 03/07/2025
Q46. Write a C# program to display the date of the previous Monday.
Output: Previous Monday: 29/12/2024
Q47. Write a C# program to find the day of the week for the first day of the year.
Input: Year: 2025
Output: First Day of the Year: Wednesday
Q48. Write a C# program to display the date of the next Sunday.
Output: Next Sunday: 05/01/2025
Q49. Write a C# program to check if the current date is the weekend.
Output: Is it Weekend: No
Q50. Write a C# program to find the last day of the previous month.
Output: Last Day of the Previous Month: 31/12/2024
Bikki Singh
Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!