>>I need to have an "if" block that checks if the current date is more >than 7 >>days later than a date in a database field. I've looked at the time >tag >and >>I'm wondering what the best way to do this would be. Any pointers >would be >>much appreciated. Thanks! >> >>- Grant > >We do some similar date comparisons for a coupon add-on that we have >implemented for a few of our clients. > >The way that we do it is to store the dates in the database in this >format: >YMD > >For instance, February 27, 2003 would be stored as: >20030227 > >You can get that value in IC by using: >[convert-date fmt="%Y%m%d"][data-session time][/convert-date] > >Then, we run similar "if" statements as the one you mentioned above by >assigning scratch variables to the two dates to be compared. > >For instance, you can set a scratch variable of today's date with >something like: > >[tmp today_date][convert-date fmt="%Y%m%d"][data-session >time][/convert-date][/tmp] > >You can then set another scratch variable with the date from the >database in a number of ways. We use a query like this: > >[query sql="select start_date, end_date from coupons where coupon_code = >'[scratch coupon_entered]'" list=1] > >[tmp coupon_date][sql-param start_date][/tmp] > >[/query] > >Finally, you can run an "if" statement comparing the two scratch >variables created above with something like this: > >[if type="scratch" term="today_date" op=">" compare="[scratch >coupon_date]"] >foo >[else] >bar >[/else] >[/if] > >Hope this helps get you started. Thanks a lot Michael. Just what I needed to know. - Grant _______________________________________________ interchange-users mailing list suppressed http://www.icdevgroup.org/mailman/listinfo/interchange-users
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.