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 / General 2 / July 2007

Tip: Looking for answers? Try searching our database.

If Statement in Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debbie - 19 Jul 2007 18:30 GMT
I am trying to write an if statement in a query that will take a text column
that shows a date (from a linked table) and convert the text to a date.  
Where the text does not have a date and is blank to convert blank data to
blank data in date conversion column.

[0572 PTA12TD TABLE].DisposalDate, DateValue([DisposalDate]) AS DisposalDates,
Above SQL converts text to date but gives an error on blank data.
Pat Hartman (MVP) - 19 Jul 2007 19:08 GMT
[0572 PTA12TD TABLE].DisposalDate,
IIf(IsNull(DisposalDate),null,DateValue([DisposalDate])) AS DisposalDates,

>I am trying to write an if statement in a query that will take a text
>column
[quoted text clipped - 5 lines]
> DisposalDates,
> Above SQL converts text to date but gives an error on blank data.
John W. Vinson - 20 Jul 2007 00:51 GMT
>I am trying to write an if statement in a query that will take a text column
>that shows a date (from a linked table) and convert the text to a date.  
[quoted text clipped - 3 lines]
>[0572 PTA12TD TABLE].DisposalDate, DateValue([DisposalDate]) AS DisposalDates,
>Above SQL converts text to date but gives an error on blank data.

IIF(IsNull([0572 PTA12TD TABLE].DisposalDate, Null, CDate([DisposalDate]))

should do the trick for you (unless the text is non-Null but also not a valid
date).

            John W. Vinson [MVP]
 
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



©2009 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.