Displaying a date

Question:
I have a date stored as an integer — days from 1/1/1900. iis there an algorithm out there to display the day, month, and year? Or is there an easy way to do this? Month seems to be the real problem because they each have a different number of days.

Answer:
Well, I’m not going to write this for you for the simple reason that the leg work and testing would be beyond the scope of this forum. But I have done stuff like this in the past and can give you some tips to get started.

First, I would divide the number by 365 to get the year and determine the month and day from what remains.

I think I would create an array of integers that hold the number of days in the month that corresponds to each item in the array. This would allow you to perform very quick look ups to determine which month; what remained would, of course, indicate the day.

Unfortunately, it is even a little more complicated than that since leap years do not contain 365 days, but I hope this will get you started.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a