Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# Date Conversion

Posted on 2011-05-09
Medium Priority
532 Views
I have dates, e.g. ,12/13/1985, which I must convert into a 5 digit number.  Is there a format for which this can be done. A Julian date gives me 7 digits plus the fractional hours and minutes. However, I need five digits. Please don't ask why.
0
Question by:gbm33
• 3
• 2
• 2
• +1

LVL 3

Expert Comment

ID: 35725962
You could write it in hex decimal

year = 3
2010 = 7da

month = 1
12 = c

day =1 or 2
1 = 1
31 = 1f

2010 12 1 = 7dac1
2010 12 31 = 7dac1f
0

Author Comment

ID: 35727924
babesia: Thank you for the suggestion. However, I must have digits, i.e., numerical only, not alpha--numeric.
0

LVL 9

Accepted Solution

Orcbighter earned 1000 total points
ID: 35729042
format DDDYY where DDD is Julian day (1 to 365) and YY id last 2 digits of year.
If YY < 20 then year = 20YY else year = 19YY
Thus
January 27 2011 = 02711;
January 27 2010 = 02710;
January 27 1978 = 02778;
November 27 2010 = 33110
0

Author Comment

ID: 35729880
Orcbighter: Indeed, your way is a way to concoct 5 digits from a date.  However, this is not the solution I will need. I think I need something that is a standard way like creating 7 digits with a Julian conversion.
0

LVL 9

Expert Comment

ID: 35737431
Hi gbm33,
The solution I gave you is a standard way for deriving a 5-digit date, with the proviso you have to have agreed on your start point in order to determine the century. I am not aware of any other.
The old standard was ddmmyy, giving six digits and sparking the whole Y2K problem. The new standard is ddmmyyyy, giving seven digits (good until the year 9999 AD).
If you want 5 digits, this is it, I think
0

LVL 41

Assisted Solution

ID: 35756522
you can get the numbers of days from 1-1-1900 to 12/13/1985, that will give you 31394

0

LVL 41

Expert Comment

ID: 35758115
Well, I have to object this. I did provided you with exactly what you asked for: a way to represent a date in a 5 digit format, which by the way is just like Excel would do it. So I don't understand why this disposition.
0

Author Closing Comment

ID: 35758180
These answers did not give me the information I needed but they both indeed do give a five digit number.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question