Solved

Access Union Query - Inconsistent Date formatting

Posted on 2011-02-24
13
456 Views
Last Modified: 2012-05-11
Hi, I'm working with a union query that brings together 8 or so queries with all identical columns, separated for ease of user entry due to the volume of information in each.

I've formatted the date field in each query to Short Date.  The individual queries look perfect.  When they're viewed in the Union Query, some (seemingly random) rows also show the time alongside the date.  

Any suggestions as to why or how to fix?  Thanks.
0
Comment
Question by:cdarbonne
  • 7
  • 6
13 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34969532
try using
 Datevalue([DateField])

instead of format
0
 

Author Comment

by:cdarbonne
ID: 34969592
Sorry to sound like an idiot - but where do I put that?  the format setting was in the properties dialog.  Is this added to the SQL in the Union Query?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34969621
<s this added to the SQL in the Union Query?> yes


select datevalue([dateField]) from table1
union all
select datevalue([dateField]) from table2

etc..
0
 

Author Comment

by:cdarbonne
ID: 34969701
Ok, here's how it looks.  I added the 'as' becuse it was naming it Exp0001.  I must still be doing something wrong becuase I get a "#Error" for some dates now

SELECT Diesel.[Product Family], Diesel.Status, Diesel.[Property/UUT], Diesel.[Test Type], Diesel.Fuel, datevalue (Diesel.[Planned/Actual SOT]) as [Planned/Actual SOT], Diesel.[ESpec CRD], Build_Schedule.[Property/UUT], Build_Schedule.[Customer MRD], Build_Schedule.[Revised Promise Date], Build_Schedule.BSS, Build_Schedule.BAS, Build_Schedule.[Build Location], Diesel.Modified, Diesel.[On HOLD?], ([Planned/Actual SOT]-[Revised Promise Date])/7 AS [PSOT-RPD DTime], (Round([PSOT-RPD DTime],1)) AS [Delta Time]
FROM Diesel LEFT JOIN Build_Schedule ON Diesel.[Property/UUT] = Build_Schedule.[Property/UUT]



Thanks again for the help
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34969737
check for NULL values on field [Planned/Actual SOT]


run a simple select query

select [Planned/Actual SOT], dateValue([Planned/Actual SOT])
from Diesel

then run this one

select [Planned/Actual SOT], dateValue([Planned/Actual SOT])
from Diesel
where [Planned/Actual SOT] <> Null
0
 

Author Comment

by:cdarbonne
ID: 34969787
Ok, did it.  Attaching results...

thanks. 1st one 2nd one
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34969807
do you want to SHOW the NULL values on field [Planned/Actual SOT] in your query?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34969825
i am also wondering, how come some records have Time values on field [Planned/Actual SOT].
do you know how this field [Planned/Actual SOT] got filled in or updated?
0
 

Author Comment

by:cdarbonne
ID: 34969850
No, I'm totally confused about that.  These tables are pulled into Access via Sharepoint.  They're linked tables.  The users enter their data in sharepoint and I pull it in to Access.  I double checked the date/time option in sharepoint and they're all set to date only.  I can't change the table formatting in Access (because Sharepoint is the boss) but I did change it in the query.  In all the queries, it looks great.  Except the union query.  That's where I'm having this issue.
0
 

Author Comment

by:cdarbonne
ID: 34969859
Oh and yes, I do want to show null values.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 34970017
you have to use this format, test this one

select [Planned/Actual SOT], IIF([Planned/Actual SOT]<> Null, dateValue([Planned/Actual SOT]),Null)  
from Diesel
0
 

Author Comment

by:cdarbonne
ID: 34970104
That works great!  Do I need to use "As" to create the properly named column?

Thank you
ee3.JPG
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34970121
<Do I need to use "As" to create the properly named column?> Yes you can.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access 2016 Debugging 7 41
bind Combobox 4 28
Why can't I get my report to SORT correctly? 5 26
Authenticate Username & Password from MS Access to Active Directory 5 44
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now