473,467 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Usage of CONVERT function in where clause (in SQLSERVER)

1 New Member
In the following query D_CNT_LINE_EXPIRE comparison with '2008-09-19' is failing altough value is there in this field. D_CNT_LINE_EXPIRE is a timestamp field in SQLSERVER table CCG03.
I doubt whether we can use CONVERT function in 'where' clause (see query 1)or 'Update set' clause' (see query 2)????????????????
let me know if need more details.
Please help folks.
query 1:
------------
UPDATE CCG03
SET C_CNT_LN_UM = 'AB'
WHERE I_CONTRACT = 12568
AND L_CNT_LINE = 17
AND CONVERT(CHAR(10),D_CNT_LINE_EXPIRE,101)
= '2008-09-19'
query 2:
------------
UPDATE CCG03
SET CONVERT(CHAR(10),D_CNT_LINE_EXPIRE,101)
= '2009-09-19'
WHERE I_CONTRACT = 12568
AND L_CNT_LINE = 17
Jan 31 '08 #1
1 4947
deepuv04
227 Recognized Expert New Member
In the following query D_CNT_LINE_EXPIRE comparison with '2008-09-19' is failing altough value is there in this field. D_CNT_LINE_EXPIRE is a timestamp field in SQLSERVER table CCG03.
I doubt whether we can use CONVERT function in 'where' clause (see query 1)or 'Update set' clause' (see query 2)????????????????
let me know if need more details.
Please help folks.
query 1:
------------
UPDATE CCG03
SET C_CNT_LN_UM = 'AB'
WHERE I_CONTRACT = 12568
AND L_CNT_LINE = 17
AND CONVERT(CHAR(10),D_CNT_LINE_EXPIRE,101)
= '2008-09-19'
query 2:
------------
UPDATE CCG03
SET CONVERT(CHAR(10),D_CNT_LINE_EXPIRE,101)
= '2009-09-19'
WHERE I_CONTRACT = 12568
AND L_CNT_LINE = 17
hi,

CONVERT(CHAR(10),D_CNT_LINE_EXPIRE,101) takes the date format as '09/09/2008' and you are comparing with '2008-09-19'
and failed

to compare both the dates use the following query

compare the date difference between two dates as
UPDATE CCG03
SET C_CNT_LN_UM = 'AB'
WHERE I_CONTRACT = 12568
AND L_CNT_LINE = 17
AND datediff(day,D_CNT_LINE_EXPIRE,'2008-09-19') = 0

thanks
Jan 31 '08 #2

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

Similar topics

2
by: jaYPee | last post by:
I have an existing query from MS Access that I want to convert it to SQL Server Stored Proc. My problem is on how to convert the WHERE clause. This is the query from MS Access: SELECT...
1
by: virendra.chandra | last post by:
hi guys, this is virendra. I am in big trouble to handle date situation using where clause. i am using ormapper. if the sqlserver and application server has different date format(different...
2
by: jaYPee | last post by:
I have no problem setting the selectcommand in sqldataadapter to fetch record from sqlserver w/ where clause in parent table. however, my problem is on how can i fetch the child table which is...
2
by: Jim.Mueksch | last post by:
I am having a problem with using calculated values in a WHERE clause. My query is below. DB2 gives me this error message: Error: SQL0206N "APPRAISAL_LESS_PRICE" is not valid in the context where...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
4
benchpolo
by: benchpolo | last post by:
I wrote a SQL script with a rxfilldate (mm/dd/yyyy format) parameter in WHERE clause. Is there way to automate the where clause to pick up the previous months data. For example: DATEPAID BETWEEN...
5
by: bobh | last post by:
Hi All, I have this query which updates a field based on the result of an IIF statement. The table is on SQLServer and I'm linked to it and it has many records and will take Access a very long...
0
NeoPa
by: NeoPa | last post by:
Intention : To prepare a WHERE clause for multiple field selection, but to ignore any fields where the selection criteria are not set. ONLY WORKS WITH TEXT FIELD SELECTIONS. Scenario : You have...
12
by: =?ISO-8859-1?Q?Ren=E9?= | last post by:
Hi, is there a rule of thumb what is better/faster/more performant in SQL Server 2005? a) SELECT * FROM A INNER JOIN B ON B.ID = A.ID AND B.Cond1 = 1 AND B.Cond2 = 2 b) SELECT * FROM A INNER...
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
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.