Hello;
I am reading a file that is ODBC-linked directly to an AS400 machine in a VBscript program within Access. One of the fields in this file automatically gets defined as a Binary data type in the Access table. On the AS400, the field contains a 6-byte date: 080822 (fmt= yymmdd). When I look at this through the VBscript debugger, I can see that the values are as follows:
value(0): 240
value(1): 248
value(2): 240
value(3): 248
value(4): 242
value(5): 242
How can I convert these values into their decimal equivalents of 0, 8, 0, 8, 2, 2?
Is it as simple as subtracting 240 from each one? And, if so, what is the technical reason behind 240?
thanks,
Gregg
7 7620 Dököll 2,364
Recognized Expert Top Contributor
Hey there Gregg!
I will send over to Access forum for a closer look... Will pop in if I find anything, just passing through as of now.
Here: http://www.google.com/search?hl=en&r...&start=10&sa=N
Actually I did a quick Google on this for ya, no real hits, but thought you could have a look while you wait:-)
Later Gregg!
ADezii 8,834
Recognized Expert Expert
Access does not have a Binary Data Type, but what the AS400 did was to convert the 6-Byte Date into a Byte() Array containing 6 (0 - 5) Elements corresponding to each Byte of the Date. A Byte is a single, unsigned 8-Bit (1-Byte) number ranging from 0 to 255. The Byte Data Type in Access is primarily used for containing Binary Data. I'm not sure what the actual values represent, but I will look further into it when I get a chance and see what I can come up with.
Hi. The AS400 minicomputer uses EBCDIC character coding, not ASCII, and as a conversion table in this link shows 240-249 (F0 hex - F9) represents the characters 0 to 9. In this instance, for the numbers 0 to 9, it is indeed safe to subtract 240 from the byte array values.
However, if at some stage you wish to convert other characters you would have to use different constants for different character groups, which you will find from the EBCDIC coding table. This non-contiguous nature arises from the history of development of EBCDIC way back to punch-card days, as EBCDIC characters were represented by byte grouping of individual 4-bit binary-coded-decimal values. The AS400 is relatively modern, introduced in 1988 and sold until quite recently, so I guess the use of EBCDIC for character storage must relate to its developmental history from mainframe architectures dating back to the sixties.
-Stewart
ADezii 8,834
Recognized Expert Expert
Hi. The AS400 minicomputer uses EBCDIC character coding, not ASCII, and as a conversion table in this link shows 240-249 (F0 hex - F9) represents the characters 0 to 9. In this instance, for the numbers 0 to 9, it is indeed safe to subtract 240 from the byte array values.
However, if at some stage you wish to convert other characters you would have to use different constants for different character groups, which you will find from the EBCDIC coding table. This non-contiguous nature arises from the history of development of EBCDIC way back to punch-card days, as EBCDIC characters were represented by byte grouping of individual 4-bit binary-coded-decimal values. The AS400 is relatively modern, introduced in 1988 and sold until quite recently, so I guess the use of EBCDIC for character storage must relate to its developmental history from mainframe architectures dating back to the sixties.
-Stewart
You are showing your age, Stewart! (LOL).
ADezii 8,834
Recognized Expert Expert
Thanks to Stewart, the mystery is solved! If you are interested in converting the Array of Byte Values to a True Date in Access, then this code should do the trick: - Dim Value(5) As Byte
-
Dim dteConvertedDate As Date
-
-
Value(0) = 240
-
Value(1) = 248
-
Value(2) = 240
-
Value(3) = 248
-
Value(4) = 242
-
Value(5) = 242
-
-
'Pass the Array of Bytes to the Function
-
dteConvertedDate = fConvertValueToDate(Value())
-
-
Debug.Print "Is it a Date: " & IIf(IsDate(dteConvertedDate), "Yes it is!", "Not a Chance")
-
Debug.Print "Month: " & Month(dteConvertedDate)
-
Debug.Print "Day: " & Day(dteConvertedDate)
-
Debug.Print "Year: " & Year(dteConvertedDate)
-
Debug.Print Format$(dteConvertedDate, "mmmm dd, yyyy")
- Private Function fConvertValueToDate(bytToConvert() As Byte) As Date
-
'Function accepts an Array of Bytes and generates a Date from them
-
'Valid only in the EBCDIC Coding Syetem and the yymmdd Format for the Date
-
Dim dteNewDate As Date
-
Dim intCounter As Integer
-
-
For intCounter = LBound(bytToConvert) To UBound(bytToConvert)
-
varDate = varDate & (bytToConvert(intCounter)) - 240
-
Next
-
-
dteNewDate = CDate(Mid(varDate, 3, 2) & "/" & Right(varDate, 2) & "/" & _
-
Left(varDate, 2))
-
fConvertValueToDate = dteNewDate
-
End Function
OUTPUT: - Is it a Date: Yes it is!
-
Month: 8
-
Day: 22
-
Year: 2008
-
August 22, 2008
ADezii 8,834
Recognized Expert Expert
Thanks to Stewart, the mystery is solved! If you are interested in converting the Array of Byte Values to a True Date in Access, then this code should do the trick: - Dim Value(5) As Byte
-
Dim dteConvertedDate As Date
-
-
Value(0) = 240
-
Value(1) = 248
-
Value(2) = 240
-
Value(3) = 248
-
Value(4) = 242
-
Value(5) = 242
-
-
'Pass the Array of Bytes to the Function
-
dteConvertedDate = fConvertValueToDate(Value())
-
-
Debug.Print "Is it a Date: " & IIf(IsDate(dteConvertedDate), "Yes it is!", "Not a Chance")
-
Debug.Print "Month: " & Month(dteConvertedDate)
-
Debug.Print "Day: " & Day(dteConvertedDate)
-
Debug.Print "Year: " & Year(dteConvertedDate)
-
Debug.Print Format$(dteConvertedDate, "mmmm dd, yyyy")
- Private Function fConvertValueToDate(bytToConvert() As Byte) As Date
-
'Function accepts an Array of Bytes and generates a Date from them
-
'Valid only in the EBCDIC Coding Syetem and the yymmdd Format for the Date
-
Dim dteNewDate As Date
-
Dim intCounter As Integer
-
-
For intCounter = LBound(bytToConvert) To UBound(bytToConvert)
-
varDate = varDate & (bytToConvert(intCounter)) - 240
-
Next
-
-
dteNewDate = CDate(Mid(varDate, 3, 2) & "/" & Right(varDate, 2) & "/" & _
-
Left(varDate, 2))
-
fConvertValueToDate = dteNewDate
-
End Function
OUTPUT: - Is it a Date: Yes it is!
-
Month: 8
-
Day: 22
-
Year: 2008
-
August 22, 2008
This is all excellent information! Thank you very much for your help!
Gregg
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Raja |
last post by:
IS there any inbuilt decimal to binary conversion function in C++
|
by: geskerrett |
last post by:
In the '80's, Microsoft had a proprietary binary structure to handle
floating point numbers, In a previous thread, Bengt Richter posted
some example code in how to convert these to python floats;
http://groups.google.com/group/comp.lang.python/browse_thread/thread/42150ccc20a1d8d5/4aadc71be8aeddbe#4aadc71be8aeddbe
I copied this code and modified it slightly, however, you will notice
that for one of the examples, the conversion isn't...
|
by: bearophileHUGS |
last post by:
Hello, I have four things to ask or to suggest, sorry if they seem
basic or already discussed.
-------------------
I am still ignorant about Tkinter. This little program, after pressing
the "Go" eats more and more RAM, is it normal? Can it be avoided? (In
normal programs this is isn't a real problem).
! import Tkinter
|
by: bowsayge |
last post by:
Inspired by fb, Bowsayge decided to write a decimal integer
to binary string converter. Perhaps some of the experienced
C programmers here can critique it. It allocates probably
way too much memory, but it should certainly handle 64-bit
cpus :)
#include <stdio.h>
#include <stdlib.h>
char * to_binary (unsigned long value) {
|
by: Amjad |
last post by:
Hi,
Are there any built-in methods in VB.NET that convert one number in one
format to its equivalent in another format?
For example I want to convert the number 162 (decimal) to 10100010 (binary)
or to A2 (hexadecimal) and vice versa.
Thanks.
| |
by: elliotng.ee |
last post by:
I have a text file that contains a header 32-bit binary. For example,
the text file could be:
%%This is the input text
%%test.txt
Date: Tue Dec 26 14:03:35 2006
00000000000000001111111111111111
11111111111111111111111111111111
00000000000000000000000000000000
11111111111111110000000000000000
|
by: zgfareed |
last post by:
My program converts decimal numbers from to binary and hexadecimal. I
am having trouble with my output which is supposed to be in a certain
format. Binary needs to be in the format of
XXXX XXXX for numbers 0 to 255. What am doing wrong or not doing with
my output?
Source code:
// code
#include <iostream>
|
by: neha_chhatre |
last post by:
which is the best format specifier(data type) if i have to work with
decimal number.
also please tell me the syntax for truncating a decimal number
please reply as soon as possible
|
by: dondigitech |
last post by:
I want to convert hex to binary without losing bits. I want to
preserve the 8-bits because I ultimately need a 24-bit string to grab
information from. I am just using this line of code for the
conversion:
string revLim = Convert.ToString(curveData, 2);
// curveData = 0x14
// I want 00010100
// I am getting 10100
|
by: RolfK |
last post by:
Dear ALL,
I have to convert a string of "10101010111"to a decimal number.
What is the standard solution in XSLT2.0 ?
Thanks a lot
RolfK
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |