Jump to content
  • 0

If else for length of time based on start date


taylorswiftlover

Question

Hi,

I'm trying to create an if/else statement for a length of time, based on a start date we put in for each client. Basically its the following:
If a person has been with our company less than 60 days, (THIS TEXT APPEARS), If a person has been with our company longer than 60 days, (THAT TEXT APPEARS)
 
Say that the field is Start_Date. 
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0
Just now, joneslovescaspio said:

Hi,

I'm trying to create an if/else statement for a length of time, based on a start date we put in for each client. Basically its the following:
If a person has been with our company less than 60 days, (THIS TEXT APPEARS), If a person has been with our company longer than 60 days, (THIS TEXT APPEARS)
 
Say that the field is Start_Date. 

I did recreate your field Start_Date and created another as Some_Date. 

Try this:

CASE
WHEN
(Datediff(day, [@field:Start_Date], [@field:Some_Date])) < 60 THEN
'
THIS TEXT APPEARS'
ELSE
'OTHER
 TEXT APPEARS'
END

 

Link to comment
Share on other sites

  • 0

I have a question regarding the 'THIS TEXT APPEARS'.

I understand that you can not use calculation inside rules, however, if I implement this CASE WHEN statement to hide or show fields, what exactly is the code for that?

Like 

CASE
WHEN
(Datediff(day, [@field:PackageStartDate], GetUTCDate())) < 60 THEN
'
HOW DO I HIDE TEXT'
ELSE

'HOW DO I SHOW TEXT'

Anyone who knows for a workaround?

Link to comment
Share on other sites

  • 0

I think you may also want to know this additional information just in case you need a formula as to how to get the number of days and hours in a single calculated field and the datatype is a timestamp and a date/time:

CAST ((Floor((Datediff(hour,[@field:DateTime],[@field:Date_Submitted])/24)) ) as VARCHAR) +
' DAY(S) '

 

Hope this helps. 

Link to comment
Share on other sites

  • 0

Add both of them: 

CAST ((Floor((Datediff(hour,[@field:DateTime],[@field:Date_Submitted])/24)) ) as VARCHAR) +
' DAY(S) ' + 
CAST(((Datediff(hour,[@field:DateTime],[@field:Date_Submitted]) - (Floor((Datediff(hour,[@field:DateTime],[@field:Date_Submitted])/24))) *24)) as VARCHAR) + ' HOUR(S) ' 

There are cases when other formula are not applicable when you are trying to add both of the equation to the calculated field. This formula works though. Hope this helps
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...