ok i have two queries pulling information from two tables.
the two queries contain identical fields however query one contains and extra field called Date and is of type Date\Time (short date)
i need to union the two queries into one including the Date field, so i created an extra field in query two and called it Date: "" as so. i did this because the next step requires identical fields.
then i created the union query combining the two queries together. All looks great until i begin looking closer. the date field that is of type Date\time is converted to text during the union because the field Date in query two is text. This is a problem for me as i need to pull information from the unioned query via the date value.
so my question is this, is there any way within query two that i can create a field of type Date\Time (Short Date) ;like i would with text IE "Date: "" "
You have essentially told us the answer yourself... rather than putting a specific Text value ("") which is only compatible with Text based data types, put Null (no value) which is compatible with most data types.
yup i understand what your saying Si thanks, but when i do create the field "Date: Date() Is Null" and then union the two queries, the conversion from Date to text still occurs. maybe im trying to do something that just isn't supposed to be done?
its very subtle but the formatting of the date from right aligned to left aligned is a dead give away that the format has changed from Date to text, thus making and attempt at determining all the records between date X and Date Y impossible.
Is there a way i can stop this so the format remains Date?
SELECT qryAssetsAttachedRules_Active02No.AppliesTo, qryAssetsAttachedRules_Active02No.HostID, tblRuleDefinitions.RuleName, tblRuleDefinitions.TypeDefinition, tblRuleDefinitions.RuleExpires, qryAssetsAttachedRules_Active02No.DateBooked, qryAssetsAttachedRules_Active02No.DateCompleted, "" AS ValidForPeriod, Date() Is Null AS ExpiryDate, "No" AS RuleExpired, "" AS [Value], "" AS ReminderDate, "" AS RuleReminder, "" AS SkillsMaintenance, tblAssets.AssetName, qryAssetsAttachedRules_Active02No.AttachedRuleRecordID, qryAssetsAttachedRules_Active02No.RuleRecordID, qryAssetsAttachedRules_Active02No.Certificate, "0" AS FollowUpVal, tblAssets.CurrentStatus, tblRuleDefinitions.Status, tblAssets.Location, tblRuleDefinitions.Export
FROM tblAssets INNER JOIN (qryAssetsAttachedRules_Active02No INNER JOIN tblRuleDefinitions ON qryAssetsAttachedRules_Active02No.RuleRecordID = tblRuleDefinitions.RuleRecordID) ON tblAssets.AssetRecordID = qryAssetsAttachedRules_Active02No.HostID;
"" AS ValidForPeriod, Date() Is Null AS ExpiryDate, "No" AS RuleExpired, "" AS [Value], "" AS ReminderDate, "" AS RuleReminder, "" AS SkillsMaintenance,
Most of those are being set to empty String values, so will be treated as text based.
The condition for ExpiryDate (Date() Is Null) actually makes it a Boolean, and due to the condition will always return False (the function Date() will always return an actual value, never a Null). What you should have for it is this:
i see your point Si and that works well for the query before it is unioned together with the first query as once they are combined the "Null" ExpiryDate field in the second query overrides the "Date" ExpiryDate field of the first and the result is no dates at all.