| ▲ | FigurativeVoid 5 days ago |
| I used to work at a company that stored all dates as ints in a YYYYMMDD format. When I asked why, I was told it was so we could subtract 2 dates to get the difference. I asked them why they couldn’t use DATEDIFF since this was in a sql db. They said they hadn’t heard of it and that it must be new. |
|
| ▲ | dguest 5 days ago | parent | next [-] |
| Wait so one day over the new year is 2025-01-01 - 2024-12-31 = 20250101 - 20241231 = 8870 i.e. 90 months and 10 days or 7 years 6 months and 10 days How is that the same thing as one day? |
| |
| ▲ | FigurativeVoid 2 days ago | parent | next [-] | | Oh it never worked. It was bad design by someone who was well meaning, but inexperienced. All these issues were resolved, usually, by parsing the date into a proper Date class. | |
| ▲ | cortesoft 4 days ago | parent | prev | next [-] | | It is even worse than that, each month boundary breaks it, too: 2025-02-01 - 2025-01-31 = 20250201 - 20250131 = 70 | |
| ▲ | rootsu 4 days ago | parent | prev [-] | | They might be subtracting taking first 4 digits and the subtracing yyyy-yyyy, mm-mm and dd-dd. | | |
| ▲ | dguest 4 days ago | parent [-] | | Which sort of works, but then you also have to deal with the cases where the days or months go negative (at the month and year bounds), and that also involves knowing how many days there are in each month. It's pretty difficult for me to imagine how this could be easier than just converting to e.g. unix time and subtracting seconds. |
|
|
|
| ▲ | jabroni_salad 5 days ago | parent | prev [-] |
| In mainframes, Julian dates are popular for that reason. YYDDD (day of year). When is 30 days after today? 25206+30 |
| |
| ▲ | alexanderchr 4 days ago | parent [-] | | Maybe I’m missing something but then what is 30 days after Christmas? 25389? | | |
| ▲ | mpyne 4 days ago | parent [-] | | 25389 mod 365, presumably. The very fancy mainframes probably would pick the appropriate modulus based on whether it was a leap year or not. | | |
| ▲ | cortesoft 4 days ago | parent [-] | | What happens when you want to add more than 365 days to a date, then? |
|
|
|