Converting from Unix Time to Other Date/Time Formats

skipmartin

New Member
Joined
Jun 27, 2002
Messages
4
I am working in msaccess and trying to take a field from a third party database and convert it to a date/time format. I am currently using the following:



Date: Format(DateAdd("s",DATA_HISTORY_HAGLOG!login,"1/1/1970 12:00:00 AM"),"m/dd/yyyy")



Signon_Time: Format(DateAdd("s",DATA_HISTORY_HAGLOG!login,"1/1/1970 12:00:00 AM"),"hh:nn:ss AM/PM")



Signoff_Time: IIf(DATA_HISTORY_HAGLOG!logout Is Null,"No Signoff",Format(DateAdd("s",DATA_HISTORY_HAGLOG!logout,"1/1/1970 12:00:00 AM"),"hh:nn:ss AM/PM"))



Logged_On_Duration: IIf(DATA_HISTORY_HAGLOG!logout Is Null,"00:00:00",Format(DateAdd("s",(DATA_HISTORY_HAGLOG!logout-DATA_HISTORY_HAGLOG!login),"1/1/1970 12:00:00 AM"),"hh:nn:ss"))



The problem is that it is converting to a text field. How can I represent as:



Date: 07/02/2003

Signon_Time: 12:30 PM

Signoff_Time: 12:45 PM

Logged_On_Duration: 00:15



Thanks in advance.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Take out the Format function from each example. However, in the case where you have "No Signoff", you may want to put Null instead (and make sure that a value is not required in the field) as a Date field cannot take both Dates and text values. I also suggest that you rename the field you call "Date" to something else to avoid confusion down the road.

For example:

Signon_Time: DateAdd("s",DATA_HISTORY_HAGLOG!login,"1/1/1970 12:00:00 AM")

HTH,

Russell
 
Upvote 0

Forum statistics

Threads
1,221,539
Messages
6,160,412
Members
451,644
Latest member
hglymph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top