Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 datetime convertion
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kond.mohan
Posting Yak Master

India
213 Posts

Posted - 02/15/2013 :  02:15:02  Show Profile  Reply with Quote
Hi all,
i have executed one query on ORACLE Server i got below output.
select * from openquery(finuat,'select (trunc(sysdate, ''MONTH'') - 1) from dual ')
output is: 2013-01-31 00:00:00.0000000.
we are trying but getting wrong data
pls provide the Convertion function in sql server



visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/15/2013 :  02:27:34  Show Profile  Reply with Quote
what should be your required output? i think it returns correct result as per expression used

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kond.mohan
Posting Yak Master

India
213 Posts

Posted - 02/15/2013 :  02:32:03  Show Profile  Reply with Quote
we fetchig in oracle query 2013-01-31
my MSSql query need to fetch the same figure.

mohan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/15/2013 :  02:57:19  Show Profile  Reply with Quote
in sqlserver you need

DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)-1

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22864 Posts

Posted - 02/15/2013 :  07:39:44  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by kond.mohan

we fetchig in oracle query 2013-01-31
my MSSql query need to fetch the same figure.

mohan


If you need only DATE part, use convert function or do it in a front end application

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000