By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,841 Members | 1,757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,841 IT Pros & Developers. It's quick & easy.

Date Compression and Recovery

RobH
P: 56
If this don't mess with your head - nothing will.

I need to take the value of now() eg 3/aug/2007 10:35pm and compress it to a much smaller code.

So far I have tried Hex(Now()) which results in 9987 which is ideal size

But how do I then get the 9987 back to a date format of 3/aug/2007 10:35pm?
Aug 3 '07 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,669
If this don't mess with your head - nothing will.

I need to take the value of now() eg 3/aug/2007 10:35pm and compress it to a much smaller code.

So far I have tried Hex(Now()) which results in 9987 which is ideal size

But how do I then get the 9987 back to a date format of 3/aug/2007 10:35pm?
I cannot for the life of me figure out why you would want to do this, but how about storing the number of seconds from an arbitrary Date/Time, say 1/1/2007 12:00 PM until Now() as in:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print DateDiff("s", Now(), #1/1/2007  12:00 PM#)
  2. 'When I ran the code line, the Date/Time was 8/2/2007 9:39:26 PM. The Output was -18437966 which you would store internally.
Expand|Select|Wrap|Line Numbers
  1. 'To retrieve the initial value of Now():
  2. Debug.Print DateAdd("s",18437966,#1/1/2007 12:00 PM#) 
  3. 'Produces 8/2/2007 9:39:26 PM
I don't really think that this is what you are looking for, but if you explain your reasoning for this request, we may be better able to arrive at a solution.

BTW, to retrieve the Decimal Equivalent of your Hexadecimal Value returned from Hex(Now()), namely 9987, you can use Val(&H9987) which would return -26233, but I really do not know what the significance of this number is right now. Good night - going to bed!
Aug 3 '07 #2

RobH
P: 56
I hope this helps..

I need to embed the date and time into a quote reference number without making it obvious that its a date and time

So the end format I'm looking for would be 7-132343.1986

The 7 representing the Sales Rep ID #
The 132343 being the consultation request #
The 1986 being the date/time code

This way I can extract the different items later for use in the admin backend.

This way the head office staff can look at a quote and know who raised the quote, what the consult request ID was and work out the date&time.

Oh its currently 12:37pm here in Melbourne, Australia. - Your the one who should be in bed :)
Aug 3 '07 #3

ADezii
Expert 5K+
P: 8,669
I hope this helps..

I need to embed the date and time into a quote reference number without making it obvious that its a date and time

So the end format I'm looking for would be 7-132343.1986

The 7 representing the Sales Rep ID #
The 132343 being the consultation request #
The 1986 being the date/time code

This way I can extract the different items later for use in the admin backend.

This way the head office staff can look at a quote and know who raised the quote, what the consult request ID was and work out the date&time.

Oh its currently 12:37pm here in Melbourne, Australia. - Your the one who should be in bed :)
How about appending something like the Julian Date and a Formatted Time to your Quote Reference Number. For instance, if I wanted to generate this number for 8/3/2007 @ 07:23:57, the code would be:
Expand|Select|Wrap|Line Numbers
  1. DateDiff("d", #1/1/2007#, Now()) & Format$(Now(), "hhmmss")
  2.  
This would produce 214072357 where 214 is the Julian Date and 072357 would be the time (7:23:57 AM) and the Quote Reference Code would now be: 7-132343.214072357. The Date/Time code is masked and easily retrievable.
Aug 3 '07 #4

Post your reply

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