MS Access: How to update a field using two other fields?

I have an access database table with three fields:

  • Date of purchase
  • Warranty Time
  • Warranty Period

The warranty time has 1, 2, 3, 4, 5 in it, which corresponds to years.

How can I automatically fill in the "Warranty Period" field (this is the date field) by looking at the "Date of Purchase" and then adding the "Warranty Time" (the warranty time will be 1 = 365 days, 2 = 730 days, etc.)?

+3
source share
3 answers

Do not use days, use the DateAdd or DateSerial function

DateSerial(Year(PurchaseDate)+WarrantyTime, Month(PurchaseDate), Day((PurchaseDate))

DateAdd("yyyy", WarrantyTime, PurchaseDate)

See: http://www.techonthenet.com/excel/formulas/dateadd.php

+8
source

?

, , , . , . , , , / . , , , - , .

+5

, , AfterUpdate, PurchaseDate WarrantyExpiry:

Me.WarrantyExpiry.Value = DateAdd("d", Me.WarrantyTime.Value * 365, Me.PurchaseDate.Value)

, sql:

UPDATE Table1 SET Table1.WarrantyExpiry = DateAdd("d",[WarrantyTime]*365,[PurchaseDate]);
-1
source

Source: https://habr.com/ru/post/1744361/


All Articles