Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / May 2005

Tip: Looking for answers? Try searching our database.

converting atomic fields to a single date time field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LAF - 25 May 2005 02:05 GMT
In importing a dbf file into Access, I have run into the following problem.  
There is a numeric 2 digit mo field, a numeric 2 digit day field, a numeric 4
digit year field, and 4 character time field with leading 0 when necessary.  
I can build an expression that creates the Short Date and Short Time format
within a single field (without the colon in Time).  However, I am having
problems getting Access to recognize this as a date time field.  Everything
is left justified in the created field, whereas when I build a data time
field from scratch with Short Date and Short Time, everything is right
justified.  Is there a straightforward expression that will combine the mo,
day, year, and time fields into a single date time field formatted by Short
Date and Short Time?

Thanks    
John Vinson - 25 May 2005 06:24 GMT
>In importing a dbf file into Access, I have run into the following problem.  
>There is a numeric 2 digit mo field, a numeric 2 digit day field, a numeric 4
[quoted text clipped - 9 lines]
>
>Thanks    

Yes:

CDate([mo] & "/" & [day] & "/" & [year] & " " & Format([time],
"@@:@@"))

This will convert 05, 24, 2005, 2325 to "05/24/2005 23:25", and CDate
will convert this text string to an Access Date/Time value (which can
then be formatted any way you please; it's stored as a Double Float
number, and the format merely controls how it's displayed).

                 John W. Vinson[MVP]    
Tim Ferguson - 25 May 2005 17:21 GMT
> I can build an expression that creates the Short Date and Short Time
> format within a single field (without the colon in Time).  However, I
> am having problems getting Access to recognize this as a date time
> field.

 UPDATE MyTable
 SET MyDateTime = DateSerial([Years], [Months], [Days]) +
   TimeSerial([Hours], [Minutes], 0)
 WHERE MyDateTime IS NULL

This works everywher because the DateSerial and TimeSerial functions are
not sensitive to regional settings.

B Wishes

Tim F
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.