PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD17] Convert Date from Unix
[WD17] Convert Date from Unix
Débuté par Gianni Spano, 23 avr. 2015 09:42 - 5 réponses
Posté le 23 avril 2015 - 09:42
Hello to all

I have a MySql database hosted on a Unix machine, created by an old programmer
who is working in our firm.
I'm able to access to this db and its tables and extract all the values stored on it.

But, i have a field called "call_date" definied as INT and i need to extract the date/time stored with this format.
Googling i found a Sql solution to see the correct date/time and i have to write:

SELECT FROM UNIX_TIME (call_date)

and the readeable date/time is shown.

I thought "IntegerToDate" was the solution, but i have an error during the execution.

Is there someone who can tell me how to obtain the converted date and time from this INT format??

Thanks in advance

Gianni
Posté le 23 avril 2015 - 10:23
if you can get the date/time with the select you mention why don't you use it to get the values you need?
did you try to execute that query using hQueryWithoutCorrection?
Posté le 23 avril 2015 - 12:38
Hi Paulo

Yes, i know what you say.
But, i'm reading records using Hreadseek and not doing a SELECT.

I was hoping there was a way to convert date from INT (unix) to real date/time format.

Thanks.

Gianni
Posté le 23 avril 2015 - 12:55
It looks like your int is the number of seconds since '1970-01-01 00:00:00' UTC
Add your int value to the seconds of a datetime variable with this value and check the results.
Posté le 23 avril 2015 - 13:45
Hi Gianno,

sure there is.. just google unix time integer format and you'll ind all the information you need...

From a quick read, it looks like the integer is the number of seconds since 19700101...

Best regards
Posté le 24 avril 2015 - 09:02
Hi to all

Found the solution...

the basic formula is: (UniDateInt/86400)+25569+(1/24)

(1/24) is for Italian timezone


nDataInt is int=1423224000 dtDataOggi is DateTime dtDataOggi=(nDataInt/86400)+25569+(1/24) // it returns the date 06/02/2015 13:00:00
Thanks

Gianni