Link to home
Start Free TrialLog in
Avatar of lthiry
lthiry

asked on

Convert date+time to double integer & back

Hi,

I would like to convert a date + time (i.e. 25/02/2003 10:53:50) into a double int and be able from this double int to recompose the date.

Is there any function that does this job ?

Thanks,

Laurent.
Avatar of Mark Franz
Mark Franz
Flag of United States of America image

No... you cannot convert a Date String into an Int.  

But I guess my first question is "why"?

CInt() will only convert a valid # not a string
Well, what exactly would this number represent?  If you can come to an agreement on that, then sure, you can convert between the two.  Maybe something like, the number of seconds since 1/1/1970 00:00:00?
Avatar of chisholmd
chisholmd

Yes you can.  Try using the Julian date format. I tried doing a quick search for a vbscript function to convert from and to julian dates.  There was lots of material available you should be able to find something that suites your needs better then I can.

Briefly a Julian Date is a number representing the number of seconds since Jan 1,1970 (I think thats the date) anyway what you'll get is a standard date format in one big number that is recognized by countless systems.

Dave


ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But that is getting away from what the original Q was, convert a Date/Time "string" into a Double...

I suppose you could use Timer() to create a numeric... but you would still have to have the original Date string to convert it back into a valid Date.

I ask again, why?
mqfranz: I don't understand what you mean.  Converting a date string and converting a date are pretty much the same thing in this context. I can't imagine another way of looking at it.

Julian dates are a standard for saving dates in a database.  If you save your dates in Julian format and someone whats to report on them with crystal reports or link them to another db there are no issues.


Avatar of lthiry

ASKER

You are right guys, it is to store the date in a database.

Basically, I am building a ticker from a database where you can schedule events as needed.

An event can start at a desired date / time, stop at a desired date/time.

But I want also to be able to put no start or ending date. If there is no start date, the ticker will start now, if it has no ending, it will never start beeing displayed.

Laurent.
Not sure if I understand that but whatever, hope we were able to help.

dave
I don't understand why you can't just store the date in the dB as DateTime?