tensixtyone

Rants of Andrew Williams / Nik_Doof

Archive for the ‘sql’ tag

SQL Server Last Full Week

with 2 comments

While writing a new report today I’ve been drove mad while creating a dynamic query that selects the last full week. So here is the code for SQL Server, to save anyone else the pain:

dateadd(dd,0, datediff(dd,0,
   dateadd(day,-1*datepart(weekday,getdate())+1,dateadd(week,-1,getdate()))
))
dateadd(dd,0, datediff(dd,0,
   dateadd(day,7,dateadd(day,-1*datepart(weekday,getdate()),dateadd(week,-1,getdate())))
))

Written by Andrew Williams

September 17th, 2008 at 2:12 pm

Posted in Projects

Tagged with , , , ,

MythTV Channel Icons

with 3 comments

I hate adding channel icons, in MythTV is one of my pet peeves. Since the last time I rescanned it has improved a little and the uk_rt XMLTV grabber now offers up lyngsat logos for the channels Radio Times cover.

Knowing of the impending doom, this time I tried to avoid it. I’ve now created a PHP script which will look through a data file, download the channel icons to the required path, and spit out a SQL script. At the moment it is very simple in that it doesn’t connect to MythTV and check what channels you have, it just blanket downloads all that it knows about.

I’ll get round to posting it in the next few days.

Written by Andrew Williams

September 28th, 2007 at 12:28 pm

Posted in General

Tagged with , , , , ,