Hello. I have a datetime field that stores data that looks like:
Unfortunately this column represents a Call Duration (in seconds). For example, in the above data the call lasted 1 minute and 28 seconds.
I can't seem to figure out how to either
1) return only the last eight characters of this field (in excel it would be the equivelent of MID, RIGHT, LEFT). From here I was thinking that I could use CONVERT?
2) convert from date/time to int which represents total seconds.
Where in foo-floggy did you get the 1899-12-30 ?!?! I've seen lots of strange values pop up in applications, but that's a new one to me! There are two different approaches to your problems (one for each problem, of course). They are:
in excel it would be the equivelent of MID, RIGHT, LEFT
you might be using a MS product what are you accessing this database with. I'd be tempted to stick this into a formatting funtion. In Access SQL you can put the function into the SQL to create a derived field in the query, you may be able to do the same or similar depending on the server you are using.
However it does sound as if the data model is either incorrectly specified or populated. What is it that is setting the day/date component. If that is consistent then you may be OK as you are. However if the vendor decides to change the baseline method between versions (its hardly unkown for suppliers to be so creative) then you could have a problem.
Personally I'd want to tie down the input so that it was only Hours/minutes/seconds, which I if couldn't get a stable method of storing that in the DB I'd probably resort to storing it as a long integer, and writing an encoding / decoding function to het back to the DD:MM:MMS value you expect to see.
Interesting. The two choices that I've seen are 1900-1-0 and 1904-1-0, which compute as 1899-12-31 and 1903-12-31. If I try to enter 1899-12-30 as a date, neither MS-Excel nor MS-Access recognize it as such, and they treat it as raw text.
Maybe it is something in the international versions? I'll have to try it on a UK machine if I have a chance tomorrow.