473,465 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Converting CHAR parameter to DATE for comparison with DATE variables

1 New Member
Im trying to develop a SQL driven report in Quality Centre using parameters. Ive set up two parameters in the 'query parameters' part of the report which are passed into the SQL, each parameter representing a date and in the format dd/mm/yyyy. I want to be able to check if a variable, of type Date, from one of our tables, falls within that date range given by the two parameters. The variable Im comparing to is of type Date and called BG_USER_30 in the below code, and I believe the parameters are of type CHAR. Ive tried casting the parameters to Date type, but I get an error stating that Date is not a valid data type (even though I have other variables of tpye date in my database). Ive also tried casting all 3 to DateTime, which passes syntax checks but doesnt yield the results im expecting. Below is the section of code which compiles but doesnt select the correct data. Im fairly new to SQL, could anyone offer any pointers as to where Im going wrong here? Is casting totally the wrong way to go? In summary im basically trying to find a way to compare the generic parameters supplied in QC with Date types.

Thanks in advance of any help,

Mike

my code so far is..

...and (cast(BG_USER_30 as Datetime) between cast(@dateone@ as Datetime) and cast(@datetwo@ as Datetime))
Then 1 ELSE 0 END)
As 'Fixed Same Day',
Apr 29 '10 #1
1 1867
ck9663
2,878 Recognized Expert Specialist
There are two ways you can handle this.
1. Do it in the front-end.
2. Do it in the back-end, but make sure to check the default of the date format of your SQL Server.

Happy Coding!!!

~~ CK
Apr 30 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Lloyd Sheen | last post by:
Below is the output from command window. This shows values of variables and result of comparison. Make no sense except to dot.net. Any ideas?? ?pofile #11/11/2003 12:39:22 PM# ?pdtdbdate
2
by: Neil Zanella | last post by:
Hello, Consider the following program. There are two C style string stack variables and one C style string heap variable. The compiler may or may not optimize the space taken up by the two stack...
20
by: Nate | last post by:
I am working on an Oakley parser and want to call an fopen function to read in the log file. I can use this to read the file, but only if I pass a "const char" variable to fopen. Since I would...
5
by: jab3 | last post by:
(again :)) Hello everyone. I'll ask this even at risk of being accused of not researching adequately. My question (before longer reasoning) is: How does declaring (or defining, whatever) a...
7
by: GRoll35 | last post by:
This is 1 source page of a project im working on. i just have this one error. i'll show the error then show the code.. i'll point out the line that it doesn't like. if anyone has any ideas or...
4
by: lada77 | last post by:
All, Just wondering if one of you very helpful guru's out there could comment on some odd behaviour I am seeing. I'm betting it is something obvious but I am not experienced enough to tell...
18
by: Martin Pöpping | last post by:
Hello, I´ve a problem with the follwing code lines: string line; ifstream myfile ("doorcoordinates.txt"); if (myfile.is_open()) { char str; char * pch;
12
by: Rob Meade | last post by:
Hi all, Ok - I've come from a 1.1 background - and previously I've never had any problem with doing this: Response.Write (Session("MyDate").ToString("dd/MM/yyyy")) So, I might get this for...
0
by: coolvivek33 | last post by:
hi i am facing a strange problem i am trying to build report using sql server 2005 and microsoft visual studio2005 now it is in requirement that i should seperate date from time.I have done that...
4
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.