In Transact-SQL, the SET DATEFIRST command is used to set the first day of the week, so when you use the DATEPART(weekday, <Date>) function, you have control on which day of the week is first. So a common requirment is to set Monday as the first day of the week, so you'll call (Where 1 = Monday):
SET DATEFIRST 1;
1 = Monday, 2 = Tuesday, 3 = Wednesday, and so forth.
Very useful, but you cannot use SET commands within a View definition, so what do you do when you want to have a certain DATEFIRST value within a view's results? Use this calculation:
SELECT ((DATEPART(weekday, <Your Date>) + @@DATEFIRST -1 -<Your DATEFIRST>) % 7) + 1
<Your Date> with the date value
<Your DATEFIRST> with your diesired DATEFIRST number
And you can wrap this in your own Scalar-valued function to simplify reuse:
CREATE FUNCTION dbo.f_WEEKDAY(@dateValue datetime, @datefirst int)
RETURN ((DATEPART(weekday, @dateValue) + @@DATEFIRST -1 -@datefirst) % 7) + 1;
I hope this comes in handy for you, it has for me.
It's been a very long time since I did any serious web development (like 8 years!!!!). Last time I did any, IE6 was still the most popular browser and cross browser compatibility was a nightmare! :S Don't get me wrong, I've still been coding, but mostly SQL, a little Windows Forms and WPF, and even a chunk of good ol' VBA in Excel.
A LOT has changed in the world of Web Development, and when I came up with (what I think is) a fairly good web/mobile app idea, I needed some serious brushing up of skills. ASP.NET Web Forms (which I was using is on the way out), in favour of ASP.NET MVC and the new .NET Core. Xamarin is now part of Microsoft and I hear good things about, so a upskilling in the latest from Microsoft is a compelling option. As I needed a fair amount of upskilling, I took a look outside the Microsoft ecosystem to see what else is out there, specifically using Python. Why Python? I dabble a fair bit in 3D, and most of the major 3D tools have a Python scripting ability, so getting familiar with Python will come in handy later on. Plus Python has a strong presence in the Big Data field, so will also come in handy there too.
So I started digging around outside the confines of Microsoft and came across a popular Python Web Framework called Django, and Django is AWESOME! It is super easy to use, fast to develop in, and forces good programing conventions. You simply define your models (and relationships), and Django takes care of all the plumbing, creating the Database and all the code needed to access it, plus it includes a dynamic Admin site that has an out of the box simple UI to manage the data (targeted to admins, not necessarily end users). It's been around for over 11 years now, and is very mature and has an extensive set of extensions. One such extension is the Django Rest Framework, which with a few lines of code I was able to wrap a full REST API around my models. Done! I hear Django is very similar to Ruby on Rails, but I have no experience with that technology to comment any further.
Below is a high level diagram of the various app components and frameworks I'm going to tackle for the app:
There is a lot to learn, so will keep me busy for a little while yet. With Django I was already able to quickly build the App Framework and the REST API, and being Django the Database and Admin website is all done too.
The blog has been quiet for the last few months. You get busy, lose momentum, and the blogging stops :(
One of the down sides of being busy is that I've barley done any artwork, which I hope to carve out some time to do again soon. Most of my free time has been spent of learning new tech (more on that later), but before then I finished off this 3D Optimus Prime model back in late June/early July. I just never got around to posting about it.
Check out the Optimus Prime (Transformers Rescue Bots) Portfolio page for more renders.
Check out the Turntable video on YouTube.
On a side note, as I've been neglecting the CG Short Showcase blog too, I've taken that offline.
Group Manager -.Data & Insights