Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sri99860
Starting Member
7 Posts |
Posted - 2013-02-26 : 02:50:00
|
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
52326 Posts |
Posted - 2013-02-26 : 03:04:28
|
what do you mean by its in varchar format? select cast(getdate() as date) will have return datatype as date not varchar------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
sri99860
Starting Member
7 Posts |
Posted - 2013-02-26 : 03:14:02
|
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 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-26 : 03:22:28
|
Which reporting tool are you using? what was your expression used?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
sri99860
Starting Member
7 Posts |
Posted - 2013-02-26 : 03:54:34
|
Reporting Tool.. Business Objects XIR3.expression used in select statement is ...cast(tablename.columnname as date) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-26 : 23:25:59
|
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 MVPhttp://visakhm.blogspot.com/ |
|
|
sri99860
Starting Member
7 Posts |
Posted - 2013-02-27 : 01:23:50
|
I tried with this function as well..but no luck.Cast fn also converts date to char.Any other suggestion..pls |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-27 : 01:25:13
|
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 MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|