473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

If DateSold is null then use Date() in workday function

I have two query expressions which works separately:
Days1:
Expand|Select|Wrap|Line Numbers
  1. IIf(IsNull([DateSold]),Date()-[DateBuy],Workdays([DateBuy],[DateSold]))
Day4:
Expand|Select|Wrap|Line Numbers
  1. Workdays([DateBuy],Date())
but when combined it does not work - too many arguments:

Days5:
Expand|Select|Wrap|Line Numbers
  1. IIf((IsNull([DateSold]),Workdays([DateBuy],Date()),Workdays([DateBuy],[DateSold])))
what is the solution please?
Oct 26 '15 #1

✓ answered by NeoPa

As Rabbit says, it should be :
Expand|Select|Wrap|Line Numbers
  1. Days5: IIf(IsNull([DateSold]),Workdays([DateBuy],Date()),Workdays([DateBuy],[DateSold]))
An alternative approach might be :
Expand|Select|Wrap|Line Numbers
  1. Days5: Workdays([DateBuy],Nz([DateSold],Date()))

5 1673
Rabbit
12,516 Expert Mod 8TB
You have an extra set of outside parentheses on your Days5 expression.
Oct 26 '15 #2
NeoPa
32,556 Expert Mod 16PB
As Rabbit says, it should be :
Expand|Select|Wrap|Line Numbers
  1. Days5: IIf(IsNull([DateSold]),Workdays([DateBuy],Date()),Workdays([DateBuy],[DateSold]))
An alternative approach might be :
Expand|Select|Wrap|Line Numbers
  1. Days5: Workdays([DateBuy],Nz([DateSold],Date()))
Oct 26 '15 #3
Thank you Rabbit for the solution.
Nov 4 '15 #4
I like the Nz suggestion, much neater. Thanks for that NeoPa.
Nov 4 '15 #5
NeoPa
32,556 Expert Mod 16PB
My pleasure Fin :-)
Nov 10 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Westcoast Sheri | last post by:
When I used the "date("nj")" function to generate an invoice, about 1 out of 500 times, nothing comes up <?php $invoicedate = date("nj"); ?> <html><head></head><body> Invoice date: <?php...
6
by: evolve | last post by:
why doesn't c# seem to support some kind of 'null date' for instance: i have an application where the user is not obliged to enter a date until an event happens (e.g. a bug was fixed on xyz) ...
1
by: Vern | last post by:
I'm using the Microsoft Enterprise Data Access block to call the stored procedure. One of the values the stored procedure returns is the stop date. When the stop date is null, the program crashes....
1
by: SirPoonga | last post by:
I need a workday function like excel has. I found vba code for access to dot he task. I want to try and convert it. One of the funcitosn has the parameter "Optional dtmDate as Date = 0". I need...
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
1
by: GB | last post by:
Is there a function to set a null date in vb.net? Normally, I create a const NULLDATE = "1/1/1900", but that becomes a drag at times. Especially, handling a nulldate from SQL into a dataset. ...
10
by: Brad | last post by:
If I need to assign a NULL value to a date variable, how would I go about doing that? For right now I am using 01-01-2001, however I don't want to use a "real" date if the date should really be...
0
by: Ronald S. Cook | last post by:
When I pass a null date from my client to my service project, it comes across as #12:00:00 AM#. While I can easily code for this, it seems like a hack. Is this normal? I'm using WCF, by the...
1
by: klove1209 | last post by:
Good afternoon, I am currently working on this unbounded form that has numerous date fields. I wanted to know if it is possible to save data in a form, with a null date field. I am currently...
1
by: mwittekiend | last post by:
I am trying to convert a NULL date to a Y/N flag. It is giving me a conversion error. Here is the code. Any help is appreciated. Thanks 'CommitDateTimeFlag' = (case when CommitDateTime IS NULL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.