473,499 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

translate SQL Server query to DB2

4 New Member
Hi everyone,

Who can help me to translate the SQL Server query to DB2 query?
The query were shown as below:
CAST( CONVERT( CHAR(2), MonthNumberOfYear) + '/ ' + '1/' + CalendarYear AS DATETIME)

Any reponse is appreciated^_^

Thanks!
Winnie
Apr 10 '07 #1
4 4145
Snib
24 New Member
If I understand that SQL correctly it is returning the date for the first day of the current month in US date format (MM/DD/YYYY).

So, something like this should do the trick:

select strip(char(month(current date))) concat '/1/' concat
char(year(current date))
from sysibm.sysdummy1
;

So for this month it would give the following:

4/1/2007

Regards

Snib
Apr 11 '07 #2
winniewang
4 New Member
I want to convert char datetype to date datetype. But I aways receive the error:The syntax of the string representation of a datetime value is incorrect. SQLSTATE: 22007, SQLCODE: -180 (Microsoft DB2 OLE DB Provider)
My query is:
date(Cast(MonthNumberOfYear AS char(2))||'/01/'||CalendarYear)
I'm sure the "Cast(MonthNumberOfYear AS char(2))" is right. And if I change my query like this: date('12'||'/01/'||CalendarYear)
It seems that the the result of "Cast(MonthNumberOfYear AS char(2))" can not use as the date's parameter...
Who can tell me what's wrong with my query?

Thanks
Winnie
Apr 12 '07 #3
chandu031
78 Recognized Expert New Member
Hi,

The problem with the query is when you cast say month number 4 as char(2) it will return '4 ' .. So you have to trim this for spaces..


Use this query :

select date(rtrim(Cast(month(current date) AS char(2)))||'/01/'||'2007' ) from sysibm.sysdummy1


Hope this is helpful..
Apr 12 '07 #4
winniewang
4 New Member
Thank you!
You are right.

Thanks
Winnie
Apr 13 '07 #5

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

Similar topics

10
2323
by: Marco Alting | last post by:
Hi, I'm still confused about my queries, I want to do something is ASP that is easily done in Access. I'll post the Access queries below as a reference. The main idea is that the queries depend...
4
4941
by: +Vice | last post by:
Can anyone help me translate this statement from using the legacy outer joins to the SQL-92 standards? Select CA.* From Customer C, Shipper S, Customer_Order CO, Cust_Address CA Where...
1
11150
by: Joe | last post by:
Hi all Is there a TSQL function like Oracle's Translate function? Where: Translate('13,000 Miles','abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, ',' ') would return '13000'? I'm...
0
2040
by: SimpleSimple | last post by:
My company has an IIS 5, ASP.net intranet site that contains documents for employee use. The files are of various types (most often Office) and are stored in blob fields in a SQL2000 database. ...
1
1210
by: rguarnieri | last post by:
I have this query in access and I need to translate to SQL ansi TRANSFORM Sum(BilletSCHQTY) AS SumOfBilletSCHQTY SELECT Tap, Mandrin, BilletOD, BilletLength, FROM Tbl_ExtruOptimize_Src GROUP...
2
2202
by: Krustov | last post by:
I'm doing whois domain checker for www.hosthome.co.uk and want to add a checking routine for the .eu tld . I have limited knowledge about sockets and stuff - so can somebody translate the info...
9
3083
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
3
12527
by: amija0311 | last post by:
Hi, I am new using DB2 9.1 database by windows base. I want to query the data that contain string then translate the string into integer using DB2. The problems is If the data is null, i got the...
4
10615
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
7134
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
7225
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
6901
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
7392
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...
1
4920
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
4605
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
3105
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
1429
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 ...
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.