Posts

Showing posts from January, 2010

Multiple Folder Watcher

In application development you can come across to scenario where you need to keep an eye on a particular folder and do some processing based on if file is added, deleted, changed or renamed in that folder. To achieve the same the best available option is to create the Windows Service Created for the same. But in case if you have multiple folders to watch from the same Windows Service than you need to use multiple instance of the FileSystemWatcher() class. Here is the sample code to watch the multiple folders: /************************************************************************/ // TODO: Add code here to start your service. _watcher = new FileSystemWatcher(); _watcher.Path = ConfigurationManager.AppSettings["ScanDocumentSharedPath"].ToString(); _watcher.Filter = "*.tif"; //_watcher.Changed += new FileSystemEventHandler(LogFileSystemChanges); _watcher.Created += new FileSystemEventHandler(LogFileSystemC...

Get first date of baselined month

I had been working on one query where I need to find the data between the date range and the start date range should be from the 1st date of month of October. So here is a simple solution for the same. What you can do is if you need April 1st to be the start of your fiscal year just change the if condition from 10 to 4 And replace '10/01' with '04/01' /*****************************************************************************************/ declare @dtFiscalYearStart datetime if (month(getdate()) Common Mistakes When Searching for Dates: When searching for dates there are a number of common mistakes that new SQL Server programmers sometimes make. In this section, I will show you two common date/time pitfalls. The intent of this first example is to select all the records in the DATE_SAMPLE table that have a SAMPLE_DATE equal to '2003-04-09'. Here is the code: "SELECT * FROM DATE_SAMPLE WHERE SAMPLE_DATE = '2003-04-09'" When this code is r...