When you write queries that involve datetime columns, it is often needed to remove time part from datetime value to compare only date part. An example would be, you have table called sales_details that has sales_date as one of the columns and you want to find out all sales that were made yesterday. In this case you need to include all times of yesterday ie remove time part and include only date part.
The simple code that finds yesterday's sales isWHERE datediff(day,sales_date,getdate())=1
But if the column sales_date is indexed, SQL Server will not make use of it because of the usage of
function over it. So the effecient method isWHERE
sales_dateThe above will return all data where sales_date contains yesterday's date. Using DATEADD and DATEDIFF is one of the ways to remove the time part. Here are all the methods that I know declare @date datetime
set @date='20120118 19:22:10'
dateadd(day,datediff(day,0,@date),0), --Method 1
cast(@date as date), --Method 2
cast(convert(char(8),@date,112) as datetime), --Method 3
cast(cast(@date as varchar(11)) as datetime), --Method 4
@date-cast(cast(@date as time) as datetime), --Method 5
@date-convert(char(10),@date,108) --Method 6
Note: Methods 2 and 5 will work from version 2008 onwards and Method 4 depends on the language of the session....(Read whole news on source site)
Today's $10 Deal of the day from APress at http://www.apress.com/9781430237860
is "The Essential Guide to HTML5 and CSS3 Web Design".
"A contemporary update of Craig Grannell
's acclaimed The Essential Guide to CSS and HTML Web Design—now featuring coverage of HTML5 and CSS3!"
There has been minor controversy over the use of upper case letters in Visual Studio 2012's menus. No need for concern. If you really hate them you can turn them off! There are three ways to do this: 1) Registry Key a) Open a registry editing tool such as RegEx.exe b) Navigate to the following node: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General c) Right-click on the node and select New | Dword value. d) Set the name to SuppressUppercaseConversion. e) Set the value to 1. 2) NuGet Package: VS2012_RemoveAllCaps a) Open Visual Studio
b) Select Tools | Library Package Manager | Manage NuGet Packages for Solution … c) The Manage NuGet Packages dialog opens. d) Type RemoveAllCaps in the search box found in the upper right corner. e) Click the Install button next to the found package.
3) Visual Studio Extension: VS Commands 2012 a) Open Visual Studio b) Select Tools | Extensions and Updates c) The Extension Manager dialog opens. d) Type Commands in the search box found in the upper right corner. e) Click the Download button to...(Read whole news on source site)
Windows 8 installs with .NET 4.5. A default installation of Windows 8 doesn't seem to include .NET 3.0 or 3.5, although .NET 2.0 does seem to be available by default (presumably because Windows has app dependencies on that). I ran into some pretty nasty compatibility issues regarding .NET 3.5 which I'll describe in this post. I'll preface this by saying that depending on how you install Windows 8 you may not run into these issues. In fact, it's probably a special case, but one that might be common with developer folks reading my blog. Specifically it's the install order
that screwed things up for me - installing Visual Studio before explicitly installing .NET 3.5 from Windows Features - in particular. If you install Visual Studio 2010 I highly recommend you install .NET 3.5 from Windows features BEFORE you install Visual Studio 2010 and save yourself the trouble I went through. So when I installed Windows 8, and then looked at the Windows Features to install after the fact in the Windows Feature dialog, I thought - .NET 3.5 - who needs it. I'd be happy to not have to install .NET 3.5, but unfortunately I found out quite a...(Read whole news on source site)
On of the issues that we have had in the office recently is that the rest of the Office, through no fault of their own, speaks and uses American English. I however along with the majority of the English speaking world use British English. Microsoft have recognised this with the inclusion of Windows 8 (English-United [...]-Are you adopting Visual Studio, Team Foundation Serve or Agile? Are you stuck in a rut? Let us help you... email
You would think that giving an application a title and later retrieving that title would be a straightforward thing to do in VB.NET or C#. But it turns out to be a little complex, especially to find the appropriate place to enter the title then to write the appropriate code to retrieve that title. First, enter the title of the application. In C#: Find the project in Solution Explorer. Double-click on the Properties node under the project in Solution Explorer. Select the Application tab.
Click the Assembly Information button. Enter the desired title into the provided dialog. In VB:
Find the project in Solution Explorer. Double-click on the My Project node under the project in Solution Explorer. Select the Application tab. Click the Assembly Information button. Enter the desired title into the provided dialog.
Second, write the code to retrieve that title. In this example, the...(Read whole news on source site)
Someone asked me about this, and though ampersands in menus is as old as VB 1.0 the question comes up because the associated shortcut keys don't appear underlined by default in some versions of Windows. Most Windows Forms applications have a menu bar at the top. The menu in my sample application looks like this:
The original Windows Forms layout standards suggested that each primary menu and menu option have an associated shortcut key. That way the user can access the menu options without having to move their hands from the keyboard. In Visual
Studio, you define the shortcut key for a menu or menu option by adding an ampersand (&) in front of the character in the menu option Text property. For example, the Text property of the Help menu above is defined as "&Help". This identifies the H as the keyboard shortcut key. The About menu option is defined as "&About", making the A the shortcut key. With Windows 7 (and Vista I believe), you don't see the keyboard shortcut key shown underlined in the menu by default. You have to press the Alt key for underlines to appear. In my...(Read whole news on source site)
Download: Windows Azure Training Kit - Microsoft Download Center - Download Details
The August 2012 update of the Windows Azure Training Kit includes 41 hands-on labs and 35 presentations. Some of the updates in this version include:
Added 7 presentations specifically designed for the Windows Azure DevCampsAdded 4 presentations for Windows Azure SQL Database, SQL Federation, Reporting, and Data SyncAdded presentation on Security & IdentityAdded presentation on Building Scalable, Global, and Highly Available Web AppsSeveral hands-on lab bug fixesAdded the Windows Azure DevCamp 1-day event agendaUpdated Windows Azure Foundation Training Workshop 3-day event agenda