473,401 Members | 2,068 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,401 software developers and data experts.

Iif/datediff

18
hi
In the below command I like to know can I combine it with the IIf function.
I am checking to see if NSCHD is blank. If it is blank I would place "no date"
in the place of the result..
"Starts In " & DateDiff("d",Format(Date(),"mm/dd"),Format([NSCHD],"mm/dd")) & " Days"


Thanks
bg
Jul 17 '07 #1
5 2579
MikeTheBike
639 Expert 512MB
Hi
hi
In the below command I like to know can I combine it with the IIf function.
I am checking to see if NSCHD is blank. If it is blank I would place "no date"
in the place of the result..
"Starts In " & DateDiff("d",Format(Date(),"mm/dd"),Format([NSCHD],"mm/dd")) & " Days"


Thanks
bg
You don't say where you are using this but I thing this would be better, it may even work!

"Starts In " & DateDiff("d",Date(),[NSCHD]) & " Days"

Why format it as you actualy state "Starts in xx Days" and the fuction is set to return days ??

Note days will not format as mm/dd correctly (I believe).

MTB
Jul 17 '07 #2
missinglinq
3,532 Expert 2GB
I'd use a simple If...Then construct rather than IIF simply because it's easier to tell at a glance what's going on, and using expressions within IFF can get complicated with hard to spot errors resulting . Also, there's no need to use formatting on your dates in the DateDiff function; you're returning a number of days, not a date. I'd do something like this:

Expand|Select|Wrap|Line Numbers
  1. If IsNull(NSCHD) Then
  2.   "No Date"
  3. Else
  4.   "Starts In " & DateDiff("d",Date,NSCHD) & " Day(s)"
  5. End If
  6.  
Good Luck!

Linq ;0)>
Jul 17 '07 #3
hariharanmca
1,977 1GB
hi
In the below command I like to know can I combine it with the IIf function.
I am checking to see if NSCHD is blank. If it is blank I would place "no date"
in the place of the result..
"Starts In " & DateDiff("d",Format(Date(),"mm/dd"),Format([NSCHD],"mm/dd")) & " Days"


Thanks
bg

Yha, you can use it like

Expand|Select|Wrap|Line Numbers
  1. "Starts In " & iif(DateDiff("d",Date,NSCHD) = 0,"No",DateDiff("d",Date,NSCHD)) & " Days"

but if Mike's qurey is workink then you can use that,
Jul 17 '07 #4
missinglinq
3,532 Expert 2GB
Didn't mean to step on your toes, Mike! Had to take the dog out between starting and ending my response. Actually the DateDiff will run with the dates formatted, it's just not necessary!

;0)>
Jul 17 '07 #5
MikeTheBike
639 Expert 512MB
Hi missinglinq
Didn't mean to step on your toes, Mike! Had to take the dog out between starting and ending my response. Actually the DateDiff will run with the dates formatted, it's just not necessary!

;0)>
That is not a problem, anything can happen between staring a post and submitting it, and offen does!

I have never tried formatting a date inside DateDiff, had no reason to (yet!), but I will take your word for it.

MTB
Jul 17 '07 #6

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

Similar topics

4
by: CJM | last post by:
I have an ASP page that lists files and folders in a directory. I'm using a cookie to record the last time this page was visited, and I intend to show links that are created/modified from that date...
8
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 ...
6
by: Lofty | last post by:
Hi all. I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days...
1
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
5
by: sr | last post by:
Anyone know of a better way to simulate a datediff for C#, i.e., without referencing the VB.NET runtime? Only added the functionality that was needed for me so it is not the full implementation...
6
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.