Solved

Access Union Query - Inconsistent Date formatting

Posted on 2011-02-24
13
475 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
 
LVL 120

Expert Comment

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

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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 120

Expert Comment

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

820 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