473,659 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Iif/datediff

18 New Member
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",Fo rmat(Date(),"mm/dd"),Format([NSCHD],"mm/dd")) & " Days"


Thanks
bg
Jul 17 '07 #1
5 2596
MikeTheBike
639 Recognized Expert Contributor
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",Fo rmat(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",Da te(),[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 Recognized Expert Specialist
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 Top Contributor
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",Fo rmat(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 Recognized Expert Specialist
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 Recognized Expert Contributor
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
4093
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 minus 30mins to the present... eg effectively new and modified files: If DateDiff("n", subfolder.DateLastModified, sLastVisit ) < 30 Then.... etc On my test machine this mechanism works OK, but on the live server (Win2k, IIS5) I get some...
8
5923
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 --------->could i get 2 years and 2 months and 1
6
16511
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 between values in the database and the current date. "No problem," thought I , "I'll just use the SQL DATEDIFF command." Heh! Well, the user interface I'm using didn't even recognise DATEDIFF as being a function, so I decided to visit the mySQL...
1
7998
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 until completion: DateDiff("d",,) is TODAY the appropriate syntax for today's date? Could the function/expression even be set up that way, or do I need to do something else to get 'days until completion'? (My Access manuals do not mention a TODAY...
4
11910
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 STARTINGDATE1 ENDINGDATE1 STARTINGDATE2
1
4979
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 blank. I've tried; > >DateDiff("y",-4,DateIn) and get errors > >Please any assistance would be greatly appreciated. >
7
15488
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 DateDiff in VB.NET which is only available in C# if you don't mind linking in Microsoft.VisualBasic.dll to your C# application. I wanted to avoid this so set about a pure C# solution which uses a combination of TimeSpan in whole days and the...
5
7231
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 of the DateDiff in the VB.NET runtime. private int DateDiff( string Interval, DateTime Date1, DateTime Date2 ) { int intDateDiff = 0; TimeSpan time = Date1 - Date2;
6
7641
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
2767
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 like datediff(mm,date1,date2) datediff(mmm,date1,date2) datediff(month,date1,date2) datediff("mm",date1,date2) datediff("mmm",date1,date2) datediff("month",date1,date2)
0
8341
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8539
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.