Incorrect Expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • csolomon
    New Member
    • Mar 2008
    • 166

    #1

    Incorrect Expression

    Hello:

    I would like to automatically calculate the time an employees' benefits will begin, which is 90 days after the hire date. I have this expression:
    Code:
    =IIf(IsNull([HireDt]),Null,IIf(Day([HireDt]+90)=1,[HireDt]+90,DateSerial(Year([HireDt]+90),Month([HireDt]+90)+1,1)))
    It does not produce the correct results.

    For example: I have a hire date 1/4/2005...it says the benefits start 5/1/05, as opposed to 4/4/05.

    What's wrong with my expression?
    Last edited by NeoPa; Feb 13 '09, 04:15 PM. Reason: Please use the [CODE] tags provided
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    As a quick response - I would say consider using DateAdd().

    Comment

    • csolomon
      New Member
      • Mar 2008
      • 166

      #3
      Thanks! that worked great

      Comment

      • DonRayner
        Recognized Expert Contributor
        • Sep 2008
        • 489

        #4
        Try it like this.
        Code:
        =IIf(IsNull([HireDt]),Null,DateAdd("d",90,[HireDt])
        Never Mind. NeoPa answerd it.

        Comment

        • csolomon
          New Member
          • Mar 2008
          • 166

          #5
          Actually, I ended up using just what you suggested, except I incremented by the month as opposed to the day.

          thanks Don!

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            You say you want to add 90 days, yet your code doesn't do this. Assuming you want to return Null if [HireDt] is null, try :
            Code:
            =[HireDt]+90
            or
            Code:
            =DateAdd("d",90,[HireDt])
            The Null should perpetuate anyway.

            PS. Please note the edit comment by your post. This is not optional. As a full member we expect you to follow the site rules.

            Comment

            • csolomon
              New Member
              • Mar 2008
              • 166

              #7
              "PS. Please note the edit comment by your post. This is not optional. As a full member we expect you to follow the site rules. "

              I note it, but as a full member, I've never known how to do this...it would have been helpful if you had said how to do this.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32669

                #8
                You've been here 11 months and made 91 posts to date, and have never bothered to check out the Help section? Remarkable. All you ask and more is there available for you to read any time.

                OK. There is a link to the Help section on every page of this site. If you go there, you will see a section called Posting Guidelines. We expect members to abide by these guidelines, but will always issue a warning (with direct links) before taking any punitive action. I'm sure you can appreciate that taking every member through them by the hand is not a practical possibility (although I've never seen any of the moderators fail to be very helpful when asked).

                Particularly, for ensuring you use the [ CODE ] tags, there is a toolbar type of thing in the posting window (looks like a hash (#)) which will place the relevant tags around any selected text. Tooltips over each button explains what they do for you.

                This is not found in the QuickReply window at the bottom of every thread, nor in the Basic Editor window if you have that selected in your profile. If you choose to use either of these options, then you are responsible for formatting the reply yourself. I can help you to select the other (more fully featured) editor if that is a problem for you.

                -Administrator.

                Comment

                • csolomon
                  New Member
                  • Mar 2008
                  • 166

                  #9
                  "You've been here 11 months and made 91 posts to date, and have never bothered to check out the Help section?"

                  --Nope, never needed to...didn't know there was an issue
                  Code:
                  Thanks for the link

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32669

                    #10
                    Originally posted by csolomon
                    I note it, but as a full member, I've never known how to do this...it would have been helpful if you had said how to do this.
                    Yet you don't seem at all embarrassed to post this. You complain something is missing, without even checking to see if it's there. Impressive.

                    Comment

                    • csolomon
                      New Member
                      • Mar 2008
                      • 166

                      #11
                      Actually, a poster edited my work before and asked me to in the future use the tags but I could never figure out how to do it...I thought I had to select something to do it Who know it was as simple as [code]...[\code] so I appreciate your pointing to it...Am I embarrassed, no, just glad I finally know how to do it so that it doesn't irritate anyone else.

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32669

                        #12
                        You shouldn't need to have to type them out manually though. here's something I just prepared to clarify things.

                        Tags are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [ CODE ] tags has a hash (#) on it. You can choose which editor to use in your profile options (Look near the bottom of the page).

                        Comment

                        • csolomon
                          New Member
                          • Mar 2008
                          • 166

                          #13
                          Code:
                          AHHHHHHHHHHH...
                          So I found the hash and I made some changes to my profile...
                          which I never paid attention to before...
                          I just started asking for help!
                          Thank you for getting me on track.
                          Last edited by NeoPa; Feb 16 '09, 03:26 PM. Reason: Added some wrapping.

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32669

                            #14
                            That's fine. When I realised what you needed to know I was happy to help.

                            Comment

                            Working...