I'm debugging someone else's 10 year old legacy .asp web application (shoot me now), and I'm trying to find the most recent records in a database table.

Why is the most recent record from September of last year?


Because they're storing the datetime value as varchar (40).

Good thing they were smart enough not to waste disk space by using varchar (255)!

  • 4
    Well. Storing datetime as varchar is stupid anyway you try. All databases with varchar also have datetime with 4 digit year support.

    And that worked fine in asp 16 years ago snd still does (have a few old asp pages still running, comming up on 14 years old).

    If built right from the start the platform is irrelevant (usually)
  • 1
    @Voxera yeah, I was being facetious with the saving storage space.

    Who the hell stores dates as a string? I hate whoever designed this.
  • 1
    Why would you use varchar anyway? Unix timestamp ftw
  • 2
    I would guess that it might have started as an offline app using single file db and when porting it they just kept the same db layout.

    I have seen those to. But even worse is when all tables are named tbl0001, tbl0002. And fields col001, col002 and so on. And in that case it even was char nit varchar ;)
Add Comment