Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Log function in Excel vs. T-SQL

Posted on 2009-05-06
5
1,129 Views
Last Modified: 2012-05-06
I am trying to do a formula in sql that I have in excel. I've cut it down to the very basics. All I want to get is LOG(0.05).

In excel I get -1.3 and in T-SQL I get -2.99.

The only difference I can think of is that in T-SQL the variable is a float.

Can someone help me or have I completely lost it?
0
Comment
Question by:jrmcintosh
  • 2
  • 2
5 Comments
 
LVL 26

Accepted Solution

by:
Chris Luttrell earned 500 total points
ID: 24322614
LOG(0.05) in Excel is Base 10 by default, use LN(0.05) for log natural.
LOG(0.05) in SQL 2008 is log natural by default, use LOG10(0.05) for Log Base 10.
0
 
LVL 22

Expert Comment

by:dportas
ID: 24322639
T-SQL's LOG() is the natural logarithm. In Excel it is base 10.

So either use the LOG10() funtion in T-SQL or the LN() function in Excel.
0
 
LVL 26

Expert Comment

by:Chris Luttrell
ID: 25357531
why did you accept dportas over my answer, what is different and mine was first?
0
 
LVL 22

Expert Comment

by:dportas
ID: 25357751
I was wondering the same thing.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question