Hi Gurus,
I have a date and I need to convert it into a HEX value with a checksum.
SCENARIO
===================
Starting point:
DateTime aDate = new DateTime(2003,05,29)
Expected Result:
07D3051DFC
Where the values represent:
07D3 the year
05 the month
1D the day
FC the sum of the above values (yyyy should be summed separating the first two bytes
from the second two bytes)
....like this ==> (yy + yy + mm + dd)
Can any C# guru provide me with a simple function that can take a date and create the expected HEX?
Many thanks in advanced,
Filippo. 2 18514
:)
=============================
private string CreateNewAuthorization()
{
string aStr;
string aYear1;
string aYear2;
string aMonth;
string aDay;
long aChkSum = 0;
DateTime aDate = new DateTime(2003,05,29);
aYear1 = aDate.Year.ToString("X").PadLeft(4,'0').Substring( 0,2);
aYear2 = aDate.Year.ToString("X").PadLeft(4,'0').Substring( 2,2);
aMonth = aDate.Month.ToString("X").PadLeft(2,'0');
aDay = aDate.Day.ToString("X").PadLeft(2,'0');
aStr = aYear1 + aYear2 + aMonth + aDay;
try
{
aChkSum = Convert.ToInt32(("0x" + aYear1), 16);
aChkSum = aChkSum + Convert.ToInt32(("0x" + aYear2), 16);
aChkSum = aChkSum + Convert.ToInt32(("0x" + aMonth), 16);
aChkSum = aChkSum + Convert.ToInt32(("0x" + aDay), 16);
}
catch (Exception ex)
{
return ex.Message;
}
// add the checksum of --> add HEX pairs (split year)
aStr = aStr + aChkSum.ToString("X");
return aStr;
}
"Filippo" <pa********@hotmail.com> wrote in message news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi Gurus,
I have a date and I need to convert it into a HEX value with a checksum.
SCENARIO
===================
Starting point:
DateTime aDate = new DateTime(2003,05,29)
Expected Result:
07D3051DFC
Where the values represent:
07D3 the year
05 the month
1D the day
FC the sum of the above values (yyyy should be summed separating the first two bytes
from the second two bytes)
....like this ==> (yy + yy + mm + dd)
Can any C# guru provide me with a simple function that can take a date and create the expected HEX?
Many thanks in advanced,
Filippo.
:)
=============================
private string CreateNewAuthorization()
{
string aStr;
string aYear1;
string aYear2;
string aMonth;
string aDay;
long aChkSum = 0;
DateTime aDate = new DateTime(2003,05,29);
aYear1 = aDate.Year.ToString("X").PadLeft(4,'0').Substring( 0,2);
aYear2 = aDate.Year.ToString("X").PadLeft(4,'0').Substring( 2,2);
aMonth = aDate.Month.ToString("X").PadLeft(2,'0');
aDay = aDate.Day.ToString("X").PadLeft(2,'0');
aStr = aYear1 + aYear2 + aMonth + aDay;
try
{
aChkSum = Convert.ToInt32(("0x" + aYear1), 16);
aChkSum = aChkSum + Convert.ToInt32(("0x" + aYear2), 16);
aChkSum = aChkSum + Convert.ToInt32(("0x" + aMonth), 16);
aChkSum = aChkSum + Convert.ToInt32(("0x" + aDay), 16);
}
catch (Exception ex)
{
return ex.Message;
}
// add the checksum of --> add HEX pairs (split year)
aStr = aStr + aChkSum.ToString("X");
return aStr;
}
"Filippo" <pa********@hotmail.com> wrote in message news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi Gurus,
I have a date and I need to convert it into a HEX value with a checksum.
SCENARIO
===================
Starting point:
DateTime aDate = new DateTime(2003,05,29)
Expected Result:
07D3051DFC
Where the values represent:
07D3 the year
05 the month
1D the day
FC the sum of the above values (yyyy should be summed separating the first two bytes
from the second two bytes)
....like this ==> (yy + yy + mm + dd)
Can any C# guru provide me with a simple function that can take a date and create the expected HEX?
Many thanks in advanced,
Filippo. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: PeterHardy |
last post by:
I'm trying to work out an average field on a report that i'm writing
and having the problem described below.
e.g. if you had 3 weeks of cash which were 0, 2, 4 then a normal
average
would be...
|
by: Amit |
last post by:
Hi:
I'm trying to manually compute the ISIZE in REORGCHK for indexes in
DB2 v8 (fp 4).
Based on the documentation in Administrative Guide for v8, for non lob
fields
ISIZE should be the...
|
by: Paul Mendez |
last post by:
Performance_Date SumOfBudget_NOI CurrYTD_BudgetNOI_Total
1/1/2004 $4,184,626.00 ?
2/1/2004 $4,484,710.00 ?
3/1/2004 $4,537,424.00 ?
4/1/2004 ...
|
by: Filippo |
last post by:
Hi Gurus,
I have a date and I need to convert it into a HEX value with a checksum.
SCENARIO
===================
Starting point:
DateTime aDate = new DateTime(2003,05,29)
Expected Result:...
|
by: hlam |
last post by:
Help - Calculating the total of a column in a data grid --
when data grid is part of Master-Detail set-up
I have setup a Master-Detail form using Visual
Studio.Net. A ListBox is the (Master)...
|
by: MrL8Knight |
last post by:
I am building a simple shopping cart and I am having problems trying to add the costs of the items to generate a total cost. I am new at this so forgive me if my technical verbiage isn’t the...
|
by: neeraj |
last post by:
Hi
Can any body give me the syntax for summing the elements of the an
array , without looping
thanks
|
by: OllyJ |
last post by:
Hi guys hope you can help
I have a text box for each day of the week in a form and numbers are entered into them (but sometimes they need to be left blank i.e. not 0). I am summing these values...
|
by: FishVal |
last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL.
So, let us say the problem is to calculate...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |