Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 2 Jahren, 10 Monaten
Letzter Beitrag:
vor 2 Jahren, 10 Monaten
Beteiligte Autoren:
Gianni Spano, Paulo Oliveira, Fabrice Harari

[WD17] Convert Date from Unix

Startbeitrag von Gianni Spano am 23.04.2015 07: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

Antworten:

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?

von Paulo Oliveira - am 23.04.2015 08:23
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

von Gianni Spano - am 23.04.2015 10:38
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.

von Paulo Oliveira - am 23.04.2015 10:55
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

von Fabrice Harari - am 23.04.2015 11:45
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

von Gianni Spano - am 24.04.2015 07:02
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.