We're measuring actual values against a target. We have a overall target for a day (a 24 hour period) but we need to calculate a target for any given time to measure our progress 'so far'.
Obviously we need to proportion the overall target to the given time; so if it's midday, then the progressive target is half the daily target, and at 6am the progressive target would be a quarter of the daily target - and so on.
What's the most efficient way to do this in SQL? There is an obvious solution but it's not very pretty - I'd ideally like to be able to convert a DATETIME
into a total number of milliseconds in a single operation.