Showing posts with label compare. Show all posts
Showing posts with label compare. Show all posts

Monday, March 19, 2012

How to take off the time part of the parameter

Hello,

How can I display data that only compare the date part (ignoring the time part) between the value of the date parameter and the database?. It displays data only if I pass the whole date (date and time)

I tried with the following query in the report services 2000, but it even didn't pass the query parse

SELECT * FROM table

WHERE (CONVERT(CHAR(8), table.PRODUCTION_DATE, 112)
= CONVERT(CHAR(8), @.parameterDate, 112))

Any ideas will be appreciated.

Thanks,

Marco

What are the data types of the column and the parameter, and what error do you get when you say it doesn't get past the parse step?|||

The message is ADO error: Line 1: Incorrect syntax near ')'

If I replace @.parameterDate with a string e.g. '' The parse is ok

I tested the same query in RS 2005 and it passes the parse

Both the column and the parameter are datetime data types

Thanks

|||

Just in case someone has the same problem:

I realized that the workaround to this is to change the sql expression entering two dates as parameters, fromDate and toDate and using the where clause as follows:

where databaseDate => @.fromDate and databaseDate <= @.toDate

regards

Marco

Wednesday, March 7, 2012

How to store OR get Time value in a column

How can i store the time value in a column. DateTime stores dd/mm/yyy hh:mm:ss , i want only hh:mm:ss , and i also may compare the the values. And also how can i get current time to a column value, something like getdate() ?

MasterG wrote:

How can i store the time value in a column. DateTime stores dd/mm/yyy hh:mm:ss , i want only hh:mm:ss , and i also may compare the the values. And also how can i get current time to a column value, something like getdate() ?

Hi MasterG,

You can use the following T-SQL to get hh:mm:ss from a datetime value;

CONVERT(CHAR(8), GETDATE(), 108)

To insert the time into a column, you could use;

INSERT
MyTable (TheTime)
VALUES
CONVERT(CHAR(8), GETDATE(), 108)

You may want to check out Books Online for further information, I also found this article which should be really interesting to you; http://sqljunkies.com/Article/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk
|||

Thanks for great solution. This one is very helpfull

Happy Coding...