Quick Fix: SQL datetime

Setup:

I was importing some records from system A to system B.  Both were using MS SQL 2008 databases.  In my stored procedure there is an insert … select … statement.

Problem:

It turns out that system A stores the date_time field for the record in UTC time and then the application displays it as local time (Central time zone in this case).  System B is less robust and assumes the date_time matches whatever the local server time is.  All users are shown records in server time, wherever the user may be located.  Depending on the setup this usually never happens.  Let’s just say I’m aware of the shortcomings of this method and I’ll leave out the cliche “if I had been in charge I would have …” comment.

This was brought to my attention by a customer who said that their system said the record occurred at August 1st at 1 PM, but the new system said it occurred August 1st at 6 PM.  This wasn’t acceptable because they needed the info to match to be sure they brought up the same record in both systems.

Fixed:

I didn’t want to hard code anything in my stored procedure like “subtract 5 hours” to convert UTC to local time.  This would work for 9 months out of the year, but when daylight savings time ends CST is -6 hours from UTC.  DST changes from year to year, and sometimes the congress changes it all together and I don’t want to build that complexity into a dumb stored procedure.

First, you can get the difference in hours between UTC and local time with this:

select datediff(hour,GETUTCDATE(),GETDATE())

Then you can use dateadd to add that offset when you are inserting from A to B:

insert into A.dbo.records
date_time
select
dateadd(hour,datediff(hour,GETUTCDATE(),GETDATE()),utc_recs.record_date) as date_time
from B.dbo.utc_records utc_recs

This is greatly stripped down of course to show just the salient point.  I hope this saves someone some time in the future.

Steven Gangstead

Note: The only site I had to consult was the msdn library on date and time functions.

Supreme 90 Cardio Challenge

I’m reviewing Supreme 90

Warm up and cool down are common on all Supreme 90 workouts and were reviewed previously.

Work out: Cardio Challenge

Length: 31:07

Equipment: Dumbbells, mat (optional)

Format:

30 sec exercise, 30 sec off.  Repeat a lot. Light weights or just body weight.

Review:

This is my favorite work out so far.  I’m highly skeptical of cardio workouts because how much cardio can you really do in the few square feet of your living room in a half hour? Especially if you’re like me and regularly go out and run for half hour/hour at a time during the week or go bike for 2/3 hours at a stretch on the weekends? I was pleasantly surprised that with a light amount of weight you get pretty thoroughly worked out in Cardio Challenge.  The pacing is good.  30 seconds recovery and a good description of the next exercise gives you ample time to switch your PowerBlock or other adjustable dumbbell.  Good variety of exercises, this is more of a total body workout than the Total Body workout.  There are no repeats, but variations mean you come back and do a similar move but with a twist — that’s exactly how a workout should be.  I think this particular workout would be well suited for a runner.  With light weights you aren’t going to be jogging through a lactic acid burn the next day, but it’s still going to build up muscle so that you don’t get that emaciated striated runner’s build.  If you are trying to get huge ripped muscles: this ain’t it.  Go to Gold’s.  My only note/tip for this workout is to go light weight for most of the exercises.  This is supposed to be cardio, you aren’t doing 8-12 slow reps with a heavy weight, you’re doing 30 seconds fast (15-20 reps) with light weight.  Since the instructor gives really vague statements like “Don’t make it heavy this is cardio, but don’t go too light either!” I’ll give a specific example.  One exeercise is a bent over row, a move that’s also in the weight lifting work outs.  I’d normally do 8 reps with 30’s, on this workout I used 15’s for the 30 seconds (not sure on reps, 20 maybe?).

Score (out of 10): 9

Compared to P90X:

The cardio workouts in P90X are Kenpo X and Plyometrics X and to a lesser extent Core Synergistics and MAYBE if you are really liberal Yoga X (I never did Cardio X, so I can’t speak for that).  I’d say that these (Kenpo and Plyo) don’t really compare chiefly because they don’t use weights.  Plyo has a different focus so if I was comparing Cardio Challenge to one P90X workout it’d be Kenpo.  Kenpo was a great workout for me the first couple weeks, but after that I got used to it and my heart rate didn’t go up very much.  I don’t think I’d have that problem with S90 Cardio Challenge because I could always go from 10s to 15s or 15s to 20s (or a 2.5 lb increment if I feel like using the PowerBlock adder weights).  S90 wins this round.

 

There is only one workout left to review, Ultimate Ball (snicker).

-Steven Gangstead

Supreme 90 Legs

Quick recap. I started to review the workouts in the Supreme 90 Day workout program, but since I recently updated my twitters to go to my faceplant and my blegs to my twits this will be the first review to go from my bleg to your face.  And Bob’s your uncle.  Basically this is the first one that might get some reads.  If you want to see the other S90 workouts I’ve reviewed they are here.

Warm up and cool down are common on all Supreme 90 discs and were reviewed previously.

Work out: Legs

Length: 22:53

Equipment: Dumbbells, Ball

Format:

1 core set (3 exercises X 2), the rest of the workout is like a bad company that doesn’t really have an org chart and thinks that’s a feature.  It’s a bunch of random squats and lunges, and at some point in the middle he says repeat it and you do some of them again. One ball set is called a Triple Header (maybe Triple Heater) and is thrown in there randomly.  Just don’t worry about the structure and follow the leader.

Review:

If your leg consisted solely of glutes and if your lower back was part of your leg then this workout would live up to its name.  As it is I left it with fresh calves and even fresher quads.  That’s not to say I’m not tired, I did get a decent workout. Twenty minutes of squats and lunges will take the spring out of anyone’s step.  There is quite a lot of variation in terms of different kinds of lunges and squats, but little variation in terms of other muscles used.  Since the same group is hammered with no rest my lunging muscles were all lunged out and I just couldn’t give a squat at the end.  The ball was used effectively except the “Bulgarian Split Squat” was real difficult to imitate and is more useful with a chair instead.  The leader’s charisma really shines through on one exercise he does with the group and he is encouraging them to stick with it and do the last couple reps with him… except two of the demonstrators are done already and are just watching him.  Truly inspirational.  Like most S90 work outs if you are using adjustable dumbbells be prepared to pause if you want to change the weights at all.  The demonstrators only use two weights though and they don’t appear to use more than 15 pounds.

Score (out of 10): 6

Compared to P90X:

P90X legs are done the same day as back (pull ups) so your legs get brief rests.  Also P90X has a whole hour so they do some useful static exercises like wall squats.  P90X also wins by recognizing that legs also have quads and calves.

 

-Steven Gangstead