Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then Else for only Date not both DateTime

Status
Not open for further replies.

Garyjr123

MIS
Sep 14, 2010
139
US
What is the best way for me to capture a change of date for a surgical appointment? Basically, the database shows changes for any changes to the date/time field and I want to capture all the appointments that have an actual date change not just a time change during the same day.

The field that captures the appointment changes is new_start_datetime and another field that says there is a change is_start_datetime_changed which is a 0 or 1 (0 = no; 1 = yes). Again, you will get a 1 if there was just a change to the surgical appointment's date or time and I want to just capture the data that has an actual date change (i.e. 12/25/10 changes to 1/3/11).

Will an IF, THEN, ELSE formula do it or is there another way to capture this data?

Thank you,

Gary
 
The following makes use of DATEPART which lets you select and compare parts of the date (obviously :D). In the example below we test Day of the first date field and confirm if there is a dfferent value in the second date field and repeat for the Month and Year. You can also do this for Hours and Minutes and so on.

Code:
if datepate("d",{datefield1}) <> datepate("d",{datefield2})or datepate("m",{datefield1}) <> datepate("m",{datefield2}) or datepate("yyyy",{datefield1}) <> datepate("yyyy",{datefield2})then
    1
else
    0
This is untested but should give you the result you require

I feel sorry for people who don't drink, when they wake up in the morning that's as good as the're going to feel all day!
 
Hi,
A simpler way would be to use a record selection formula like:
Code:
is_Start_DateTime-Changed = 1 
and
Date({Table.Original_Start_DateTime}) <> Date({Table.New_Start_DateTime})

The Date() function, when used with a DateTime field, extracts just the Date part of the field.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top