• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

Comparing two dates

This do not work:

@If(Date1 < Date2: Date1)

I checked the Help files...  Don't know if the @Compare should be better, anyway, I don't understand how the @Compare command works!
0
barbotte
Asked:
barbotte
1 Solution
 
p_parthaCommented:
Try putting @texttotime around the formula

i.e @if (@texttotime(date1)<@texttotime(date2);Date1;"")

Partha
0
 
barbotteAuthor Commented:
ERROR: Incorrect data atype for operator or @Function

I've put:

@If(@TextToTime(Date1) < @TextToTime(Date2): Date1)
0
 
p_parthaCommented:
what is that ":", use semicolon and also check whether date1 or date2 is null

Partha
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
barbotteAuthor Commented:
This doesn't work either

@If(@TextToTime(Date1) < @TextToTime(Date2); Date2;"")
0
 
barbotteAuthor Commented:
There's a value in each Date1 and Date2 fields (field type: Date/Type)
0
 
Bozzie4Commented:
An @if statement needs 3 parts, first the condition, then the "true" case, then the "false" case

@If(Date1 < Date2; Date1; Date2)

cheers,

Tom
0
 
barbotteAuthor Commented:
oops, Date/Time I meant
0
 
p_parthaCommented:
Where have you written this formula

partha
0
 
barbotteAuthor Commented:
Bozzie4 solutions works!

Thanx!
0
 
barbotteAuthor Commented:
I was writing the condition in the formula zone of a column in a view
0
 
qwaleteeCommented:
Please check that:

1) Date1 is a date field
2) Ditto Date2
3) Each of them has a VALID date in the field

Also, what are you trying to accomplish?  Usually, you use @if thusly: @If(condition; value_if_condition_true; value_if_condition_false)

You have condition as: Date1 < Date2 : Date1
But you don't have either of the value_if_condition_xx sections.

Perhaps you meant:
If Date1 < Date2
    Then Use Date1
    Otherwise, use Date2

That would be: @If(Date1<Date2; Date1; Date2)

But date1 and date2 would still have to be two valid dates in a adate field.  Neither one can be blank.  If you need to account for blanks, use:
@If(Date1 = ""; Date2; Date2= ""; Date1; Date1<Date2; Date1; Date2)

That says:
If date1 is blank
    Then use date2
Otherwise, if date2 is blank
    Then use date1
Otherwise, if date1 is less than date2
    Then use date1
Otherwise, in any case,
    Use date2
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now