English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

wat ud be the code to check the difference between two dates,display the days and month in between.

2007-01-15 23:19:07 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

to check the difference between two dates you can simply subtract one field from another providing they are a date format field. If they are not a date format field, and are instead a text field you can use the ctod(<>). You could then subtract the fields as follows:

ctod(<>) - ctod(<>). (Don't use the >>, just to denote fieldname).

The result will be the difference between the two dates will be the number of days. for instance ctod('1/15/2007')-ctod('1/15/2006') equals 365.

If you want to display just the month, you would use the month command. ex. month(ctod(('1/15/2007'))) = 1. You can also replace month command with year and in the above example it would return 2007. There is also a day() command and if month was replaced in the above example with day, it would return 15.

I'm not quite sure what you mean by display the month and days in between, but if you want to clarify I would be more than happy to answer that as well.

2007-01-16 02:20:53 · answer #1 · answered by joshblev2 3 · 0 0

set date brit
set cent on

public fdate,sdate,noofdays,noofmnth,fmnth,smnth
store ctod('01/04/2006') to fdate
store ctod('17/08/2006') to sdate
noofdays = sdate - fdate

fmnth = month(fdate)
smnth =month(sdate)
noofmnth = smnth - fmnth
? noofdays,noofmnth

u can also use year() function to determine which year to find no. of months. if dates are spread not across one year.

2007-01-16 23:34:43 · answer #2 · answered by lakshmi r 4 · 0 0

set date brit
set cent on

public fdate,sdate,noofdays,noofmnth,...
store ctod('01/04/2006') to fdate
store ctod('17/08/2006') to sdate
noofdays = sdate - fdate

fmnth = month(fdate)
smnth =month(sdate)
noofmnth = smnth - fmnth
? noofdays,noofmnth

u can also use year() function to determine which year to find no. of months. if dates are spread not across one year.

2007-01-17 06:35:26 · answer #3 · answered by No Picture 2 · 0 1

fedest.com, questions and answers