Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts

Friday, November 18, 2011

Get the the difference between two dates in MS SQL

The DATEDIFF() function returns the difference between two dates
Syntax: DATEDIFF ( datepart , startdate , enddate )

Following is an example for the DateDiff()
DECLARE @startdate datetime ='2011-11-14 02:00:06.957';
DECLARE @enddate datetime = '2011-11-16 05:00:15.490';
SELECT DATEDIFF(day, @startdate, @enddate) as dayDifference,DATEDIFF(HOUR, @startdate, @enddate)as hourDifference
Output

dayDifference hourDifference
2 51


Similarly the following are the available datepart Options on the DateDiff() Function.

year(or yy or yyyy)
quarter(or qq or q)
month (or mm or m )
dayofyear(or dy or y )
day (or dd, d )
week(or wk or ww)

hour(or hh)
minute(or mi or n)
second(or ss or s )
millisecond(or ms)
microsecond(or mcs)
nanosecond(or ns)
TZoffset(or tz)
ISO_WEEK(or isowk or isoww)


Read More...

Get the Row Numbers as a separate column on MS SQL Query

I was trying to execute a new query where I need the Row number as a new column on the result itself. I used the SQL Function ROW_NUMBER() to get the row number.
Following query gives the Report Path with the HitCount along with the added Row Number.

select ROW_NUMBER() OVER(ORDER BY count(ReportPath) DESC) AS 'Row Number', ReportPath,count(ReportPath) as HitCount
FROM [ReportServer].[dbo].[ExecutionLog2]
Group by ReportPath
Order by HitCount desc


Cheers !
Read More...

Friday, July 8, 2011

Get the Disk Usage Statistics from the WinDirStat !

WinDirStat is an opensource tool to identify howmuch of disk space you are using on your wondow box. It shows disk, file and directory sizes in a treelist as well as graphically in a treemap, much like KDirStat or SequoiaView.

Once i started using it, i feel like life would have been very hard without it.
Why don't you try it yourself.

You can download the tool from http://windirstat.info/

Read More...

Friday, June 17, 2011

Date Conversion from YYYY-MM-DD HH:MM:SS:MMM to YYYY-MM-DD 00:00:00:000 !

Just keeping it handy !

declare @StartTime as DateTime
set @StartTime= dateadd(dd,0, datediff(dd,0,'2011-06-08 11:18:26.000'))
select @StartTime as StartTime


Read More...

Tuesday, November 3, 2009

Converting Groovy Array type to Java Array Type

Following is the code snipped in groovy that demonstrate the conversion Groovy Array type to Java Array Type.
Code for Groovy

def param=[]
param+="paramater 1"
param+="paramater 2"
param+="paramater 3"
param+="paramater 4"
def stringArgForJava = (String[])params


Test.callJavaClass(stringArgForJava) //static method


The sample java class is as follow;

class Test
{
public static void callJavaClass(String[] arg)
{
for(int i=0;i {
System.out.println("params "+i ":" +params[i]);
}

}
}








Read More...

Tuesday, October 13, 2009

Read a variable defined on the config file from a controller in a grail application



Let's say, you have the config.groovy file as follow.


...........
..........

environments {
production {
myVariable1="I am variable1 on RPOD"
myVariable1="I am variable1 on RPOD"
}



development {
myVariable1="I am variable1 on DEV"
myVariable1="I am variable1 on RPOD"
}

log4j {
appender.stdout = "org.apache.log4j.ConsoleAppender"
.........
........

Now the above varaible can be easily access through any of the controller as follow.


def config = ConfigurationHolder.config
def myVaraible1 = config.myVaraible1
def myVaraible2 = config.myVaraible2



Read More...

Wednesday, July 8, 2009

Reading the status code of HTTP Request !

When you make an HTTP request to any server url throuh your client software, lets say IE, HTTP Status codes are returned by the server to the client software to determine the outcome of your request. There are five different classes of status code range. They are
Status codes 100-101
Status codes 200-206
Status codes 300-307
Status codes 400-417
Status codes 500-505

Following is a simple program written in groovy that checks and returns the status code of any url.

import java.net.URL;
def url
def message =""
boolean fail=true
def urlString="http://192.168.0.1/test/test.html"
println checkURL(urlString)

def checkURL(urlString){
int status_code
def tempmessage=""
URL URLserver = new URL("urlString");
try{
URLConnection connection = (HttpURLConnection)URLserver.openConnection();

status_code = connection.getResponseCode();


switch (status_code)
{
case 200:
tempmessage=" Connection Successful"
break;
case 401:
tempmessage="UnAuthorised"
break;
case 405 :
tempmessage= " Resource Not Found"
break;
case 408:
tempmessage="Request Time-out"
break;
case 500:
tempmessage="Internal Server Error"
break;
case 502:
tempmessage="Bad Gateway"
break;
case 503:
tempmessage="Service Temporarily Unavailable"
break;
default :
tempmessage= connection.getResponseMessage()
break;

}
}
catch (Exception exc){
tempmessage=exc

}

return "\n "+urlString+" :"+status_code+":"+tempmessage;

}




Visit http://www.w3.org/Protocols/HTTP/HTRESP.html for detail about the status codes.



Read More...

Friday, June 12, 2009

Problems with Hotmail login

Hotmail has been going under the planned maintenance on its servers, So you might face some problem accessing your hotmail. Some of the problems that I am facing are like
1. Asking to enter password for multiple times
2. When i type in the address http:// hotmail.com in the address bar and enter than I get a message “The requested URL could not be retrieved”. Sometimes it loads the page but once I enter the password and username it throws the message “The requested URL could not be retrieved”, i.e. the connection timed out.
3. Some time I am able to log in but I get the same problem while sending or opening a message.
Solution:
Following are some of the solutions recommended by Microsoft,.
1. http://windowslivehelp.com/solutions/servicemgt/archive/2008/12/26/what-to-do-if-you-can-t-sign-into-windows-live-hotmail.aspx
2. http://windowslivehelp.com/solutions/accounts/archive/2009/03/03/How-to-optimize-Internet-Explorer-browser.aspx
3. http://windowslivehelp.com/solutions/servicemgt/archive/2008/08/22/how-to-determine-which-server-you-are-on.aspx
Read More...

Thursday, May 28, 2009

Microsoft to replace its live search engine with a new decision based engine “ Bing”


In order to compete with the giant search engine, Google, Microsoft has unveiled its new search engine, Bing. On May 28, 2009, Microsoft CEO Steve Ballmer has announced the new incarnation of live search as Bing, formerly code-named "Kumo". Bing is fully available from June 3, 09.
Microsoft has claimed that Bing is not only the search engine but a Decision Engine, designed to empower people to gain insight and knowledge from the Web, moving more quickly to important decisions.
“Today, search engines do a decent job of helping people navigate the Web and find information, but they don’t do a very good job of enabling people to use the information they find,” said Steve Ballmer, Microsoft CEO. “When we set out to build Bing, we grounded ourselves in a deep understanding of how people really want to use the Web. Bing is an important first step forward in our long-term effort to deliver innovations in search that enable people to find information quickly and use the information they’ve found to accomplish tasks and make smart decisions.”

Microsoft has aimed to gun down Google with Bing. Microsoft has already announced an $80 to $100 Million ad campaign for Bing. Google has spent about $25 million on all its advertising last year with $11.6 million for recruiting.
As show in the graph Microsoft search market share has been lowering down with just an 8.2% share of the market for core search compared to 64.2% for Google and 20.4% for Yahoo. Microsoft has been struggling to for improving its search advertisement revenue. Last year only Microsoft has offered more than $47 billion dollar bid. They might come up with another Microsoft-yahoo search deal by mid July.
Good luck to the Microsoft for the new product!






Read More...

Pages

 ©mytechtoday.com 2006-2010

 ©Mytechtoday

TOP