Store neutral date in database
-
Hello all I am building a website and I want to store the current time in a database, thats not a problem. But I also want to make the time format changable. For example if I have "May 2 2009" stored in the database and I decide I want to change the format to "5/2/2009", I need to either update the database or use a neutral date format that can be converted to the date format I want. Any tips on this? I thought about using timestamp, but cant rellay see where it fits in Thanks
-
Hello all I am building a website and I want to store the current time in a database, thats not a problem. But I also want to make the time format changable. For example if I have "May 2 2009" stored in the database and I decide I want to change the format to "5/2/2009", I need to either update the database or use a neutral date format that can be converted to the date format I want. Any tips on this? I thought about using timestamp, but cant rellay see where it fits in Thanks
-
What do you mean?
-
What do you mean?
He means that a datetime is a number[^], and as such, is neutral. To quote; SQL Server uses 8 bytes to store the datetime data type. The first 4 bytes make up an integer value that represents the number of days since January 1, 1900. The second 4 bytes are an integer value that represents the number of milliseconds since midnight. When you send a date to the database, do you convert it to a
string
that get's included in your (text) command? If so, then you can get errors converting from/to the wrong format. If you send it as a number, then it will be interpreted as a "days past since date 1"-number. Try casting a date to float/integer, and see what happens :)I are troll :)