Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Normalizing Dates Expand / Collapse
Author
Message
Posted Friday, August 29, 2003 12:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, December 07, 2010 6:58 AM
Points: 115, Visits: 17
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/jwiner/normalizingdates.asp


Post #15799
Posted Friday, September 05, 2003 4:38 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Saturday, April 12, 2014 10:26 AM
Points: 1,317, Visits: 958
Jon,
1) I've done the same thing for the same problem.
It's also an easy way to detect missing samples, i.e. you expect a value every 1 hour, but the one at 23:00 yesterday is missing.
2) It's fast. My clients DB is 4 GB, and it just flies.
3) Joe Celko has an article about a calendar that is worth reading.
4) what are you doing about Day-Light-Saving ? Every year there are missing data in the spring, and extra data in the Autumn. I have no solid solution for this problem, yet.
Regards,
Henrik Staun Poulsen
Stovi Software
Denmark




Post #77258
Posted Friday, September 05, 2003 5:12 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 21, 2011 12:23 PM
Points: 29, Visits: 13
Great Article! I write SP's to manuipulate gas usage data for my company and you gave me some good ideas. The daylight savings issue is a big issue but I just sum the data for the extra hour and leave the missing hour blank.




Post #77259
Posted Friday, September 05, 2003 6:11 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, December 07, 2010 6:58 AM
Points: 115, Visits: 17
Glad to hear others have encountered similar problems and attacked them with similar solutions...was never sure if I was off base or not with my approach. Its always nice to be validated.

Honestly, I never considered the daylight savings time issue until the two of you mentioned it...thanks for the heads up. Though the more I think about, I'm not sure if collecting data in the traditional way and tagging it with a datetime value would resolve the daylight savings time either.

Do you happen to have a link to the Joe Celko Calendar ariticle...I wouldn't mind giving it a read.

Thanks again for the input.




Post #77260
Posted Friday, September 05, 2003 6:27 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 21, 2011 12:23 PM
Points: 29, Visits: 13
Sorry don't have a link to that article. Your right about traditional data collection, the DST issue is a tricky one. I have a DST proceedure that runs parrallel with the data collection\append process.




Post #77261
Posted Friday, September 05, 2003 8:12 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, March 06, 2008 6:06 PM
Points: 644, Visits: 2
Maybe I'm totally off here, but if you add another datetime column defaulting to getutcdate() (instead of getdate()) you could solve your DST problems by using the change in time difference to separate the doubled up hour records.
The blank hour is still going to be blank because there was no such hour!





Post #77262
Posted Friday, September 05, 2003 10:21 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, February 11, 2009 8:57 AM
Points: 619, Visits: 8
pshotts,

I don't know for the utc date.
We have a third party helpdesk application which stores the dates as UTC dates.
Now I have to query the past data and I just simply do not know when a specific ticket was open. my query works fine for the actual data but before and after the daylight saving change it cause an error.
As an example: I'm checking how meny tickets are opened per hour and per day and also when my customers starts calling my helpdesk.

Right now I do not know if in march really they started to work at 8 or (as usual) at seven., because my report shows me 7 o'clock.

So UTC or not UTC.....

Bye
Gabor





Bye
Gabor
Post #77263
Posted Friday, September 05, 2003 12:56 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 1:31 PM
Points: 1,307, Visits: 779
Jon;

I like the idea of having the extra columns available for utility purposes. I think, however, that it's a mistake to define the columns and then populate them as your stored proc is doing.

This technique opens you up to data errors. What prevents an incorrect value in any of the derived date variables?

Perhaps a better approach would be to use computed columns or a VIEW that calculates all of the derived date information.

TroyK




Post #77264
Posted Friday, September 05, 2003 1:06 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, December 07, 2010 6:58 AM
Points: 115, Visits: 17
Hi Troy,

Not sure I follow you in regards to incorrect data within the date variables. Could you elaborate?




Post #77265
Posted Friday, September 05, 2003 1:45 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, March 06, 2008 6:06 PM
Points: 644, Visits: 2
Jon,

I agree with you that there should be no problem with your table.
The only reason for using calculated date(part)s would be if you need to use relative date ranges ie Previous Quarter, This Quarter or whatever.
You might like to take a look at my date ranges function:
http://www.sqlservercentral.com/scripts/contributions/864.asp
(There is a new improved version waiting for approval - Mail me directly if you are interested)
It only goes down to the level of a whole day, but there is no reason not to expand it down to the quarter hour level you are interested in.




Post #77266
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse