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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Remove Timestamp
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sri99860
Starting Member

7 Posts

Posted - 02/26/2013 :  02:50:00  Show Profile  Reply with Quote
I am new to SQL Server(2008) and after going through all the blogs in google and posting this query i.e.

Commands to be converted for the below ones in date format data type only(not in char/varchar).
1. Remove timestamp.
select cast(getdate() as date) <-- but it is in varchar format.

2. Syntax to convert the below result from Char to Date data type CONVERT(datetime,CONVERT(varchar,DATEADD(year,-2,GETDATE()),105),105)



Thanks,
Sri

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/26/2013 :  03:04:28  Show Profile  Reply with Quote
what do you mean by its in varchar format?
select cast(getdate() as date) will have return datatype as date not varchar

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

Go to Top of Page

sri99860
Starting Member

7 Posts

Posted - 02/26/2013 :  03:14:02  Show Profile  Reply with Quote
Visakh,..Thanks for your prompt response.
I am using one of the reporting tool.
However it is not allowing me to parse the syntax 'Expression type is not compatiable with the object type'. However in DB it is working fine.

If i select the data type to char, then it is parsing.

pls advice
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/26/2013 :  03:22:28  Show Profile  Reply with Quote
Which reporting tool are you using? what was your expression used?

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

Go to Top of Page

sri99860
Starting Member

7 Posts

Posted - 02/26/2013 :  03:54:34  Show Profile  Reply with Quote
Reporting Tool.. Business Objects XIR3.

expression used in select statement is ...
cast(tablename.columnname as date)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/26/2013 :  23:25:59  Show Profile  Reply with Quote
Sorry I dont know about Business Objects. Only thing is I'm sure is that cast(tablename.columnname as date) will always have return type as date

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

Go to Top of Page

sri99860
Starting Member

7 Posts

Posted - 02/27/2013 :  01:23:50  Show Profile  Reply with Quote
I tried with this function as well..but no luck.

Cast fn also converts date to char.

Any other suggestion..pls
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 02/27/2013 :  01:25:13  Show Profile  Reply with Quote
quote:
Originally posted by sri99860

I tried with this function as well..but no luck.

Cast fn also converts date to char.

Any other suggestion..pls


can i ask what exactly you're trying to do?

is it to show date in some specific format in reports?

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.11 seconds. Powered By: Snitz Forums 2000