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()) <= 10) --This will check for the Month of October in this case set @dtFiscalYearStart = convert(datetime, convert(varchar(4),(year(getdate()) -1)) + '/10/01',21) else set @dtFiscalYearStart = convert(datetime, convert(varchar(4),(year(getdate()))) + '/10/01',21) select @dtFiscalYearStart /*****************************************************************************************/ Common Mistakes When Searching for Dates: When searching for dates the