Monday, October 21, 2013

SQL SERVER – Query to Find First and Last Day of Current Month

 Following query will run respective to today’s date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month.



DECLARE @mydate DATETIME
SELECT @mydate GETDATE()
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) ,'Last Day of Previous Month'UNION
SELECT 
CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101AS Date_Value,'First Day of Current Month' AS Date_Type
UNION
SELECT CONVERT(VARCHAR(25),@mydate,101AS Date_Value'Today' ASDate_Type
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101) ,'Last Day of Current Month'
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))-1),DATEADD(mm,1,@mydate)),101) ,'First Day of Next Month'
GO

Friday, October 11, 2013

Get debug console log in iOS

- (NSString *)getConsoleLogFilePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
if (!documentsDirectory) {
NSLog(@"Documents directory not found!");
return nil;
}
return [documentsDirectory stringByAppendingPathComponent:fileName];
}


NSString *fileName = @"xx.log";
NSString *logFilePath = [self getConsoleLogFilePath];
freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr);




Swift Operators - Basic Part 3 (Range operators in swift)

Range Operators: Closed Range operators  Half-Open Range Operators One-Sided Ranges Closed Range Operators:  a...b It defines...