|
 |
asp_databases thread: Number of days
Message #1 by "Rakesh Parekh" <rakesh.parekh@j...> on Fri, 13 Sep 2002 09:15:09
|
|
Hello,
I have a date field in my database. I want to calculate and show the number
of days between a date given in my database and current date. The date in my
database is in "dd/mm/yyyy" format. For example:
Dim DBDate '(date in database)
DBDate = fp_fieldVal(fp,rs ("Committed_Date") 'Date from recordset
Dim CurrentDate
CurrentDate = Date()
No_of_Days = DBDate - CurrentDate
The above code gives me following error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "17/08/2002"]'
/mysite/final-1.asp, line 187
Perhaps it tells me to convert the database date into a string however, I
tried with CStr() function but it didn't work. When I use a fixed date with
above code i.e.
Days = (#17/08/2002# - Date()) then it works but there are different dates
in my database.
I also used the:
No_of_days = DateDiff("d", CurrentDate, DBDate)
It works 95% but surprisingly gives wrong value in some of the calculations
!!!!!!!
Please help.
Thanks,
Rakesh
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 13 Sep 2002 14:46:00 +1000
|
|
What database are you using?
Also, databases store dates as numbers, not in dd/mm/yyyy format - that's
just how the database displays it to you when you want to look at it.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Rakesh Parekh" <rakesh.parekh@j...>
Subject: [asp_databases] Number of days
: Hello,
:
: I have a date field in my database. I want to calculate and show the
number
: of days between a date given in my database and current date. The date in
my
: database is in "dd/mm/yyyy" format. For example:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #3 by Vijay G <happygv@y...> on Fri, 13 Sep 2002 07:36:54 -0700 (PDT)
|
|
If your database is in SQL, Use DateDiff function to return the value....
Cheers!!!
Vijay G
Rakesh Parekh wrote:Hello,
I have a date field in my database. I want to calculate and show the number
of days between a date given in my database and current date. The date in my
database is in "dd/mm/yyyy" format. For example:
Dim DBDate '(date in database)
DBDate = fp_fieldVal(fp,rs ("Committed_Date") 'Date from recordset
Dim CurrentDate
CurrentDate = Date()
No_of_Days = DBDate - CurrentDate
The above code gives me following error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "17/08/2002"]'
/mysite/final-1.asp, line 187
Perhaps it tells me to convert the database date into a string however, I
tried with CStr() function but it didn't work. When I use a fixed date with
above code i.e.
Days = (#17/08/2002# - Date()) then it works but there are different dates
in my database.
I also used the:
No_of_days = DateDiff("d", CurrentDate, DBDate)
It works 95% but surprisingly gives wrong value in some of the calculations
!!!!!!!
Please help.
Thanks,
Rakesh
---------------------------------
Do you Yahoo!?
Yahoo! News - Today's headlines
Message #4 by "Rakesh Parekh" <rakesh.parekh@j...> on Sat, 14 Sep 2002 04:16:31
|
|
Hello Ken,
I use Microsoft Access as my database. What you have replied is clear to
me but then what is the solution that I can calculate number of days
between current date and a date in Microsoft Access database with
Date/Time type.
Thanks,
Rakesh
====================
> What database are you using?
Also, databases store dates as numbers, not in dd/mm/yyyy format - that's
just how the database displays it to you when you want to look at it.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Rakesh Parekh" <rakesh.parekh@j...>
Subject: [asp_databases] Number of days
: Hello,
:
: I have a date field in my database. I want to calculate and show the
number
: of days between a date given in my database and current date. The date in
my
: database is in "dd/mm/yyyy" format. For example:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #5 by "Rakesh Parekh" <rakesh.parekh@j...> on Sat, 14 Sep 2002 04:18:04
|
|
Hello Vijay,
I use Microsoft Access as my database. What you have replied is clear to
me but then what is the solution that I can calculate number of days
between current date and a date in Microsoft Access database with
Date/Time type.
Thanks,
Rakesh
>
If your database is in SQL, Use DateDiff function to return the value....
Cheers!!!
Vijay G
Rakesh Parekh wrote:Hello,
I have a date field in my database. I want to calculate and show the
number
of days between a date given in my database and current date. The date in
my
database is in "dd/mm/yyyy" format. For example:
Dim DBDate '(date in database)
DBDate = fp_fieldVal(fp,rs ("Committed_Date") 'Date from recordset
Dim CurrentDate
CurrentDate = Date()
No_of_Days = DBDate - CurrentDate
The above code gives me following error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "17/08/2002"]'
/mysite/final-1.asp, line 187
Perhaps it tells me to convert the database date into a string however, I
tried with CStr() function but it didn't work. When I use a fixed date
with
above code i.e.
Days = (#17/08/2002# - Date()) then it works but there are different dates
in my database.
I also used the:
No_of_days = DateDiff("d", CurrentDate, DBDate)
It works 95% but surprisingly gives wrong value in some of the
calculations
!!!!!!!
Please help.
Thanks,
Rakesh
---------------------------------
Do you Yahoo!?
Yahoo! News - Today's headlines
Message #6 by Vijay G <happygv@y...> on Fri, 13 Sep 2002 20:58:29 -0700 (PDT)
|
|
Rakesh,
I just checked, in access too you can use the datediff() for finding difference between 2 dates.
Also In VB there is a datediff() method to find diff between 2 dates.
in access - select datediff('d',dateField,date()) from table1
in VB - datediff('d',FieldValueFromDatabase,date())
Let us know the result.
Cheers!!!
Vijay G
Rakesh Parekh wrote:Hello Vijay,
I use Microsoft Access as my database. What you have replied is clear to
me but then what is the solution that I can calculate number of days
between current date and a date in Microsoft Access database with
Date/Time type.
Thanks,
Rakesh
>
If your database is in SQL, Use DateDiff function to return the value....
Cheers!!!
Vijay G
Rakesh Parekh wrote:Hello,
I have a date field in my database. I want to calculate and show the
number
of days between a date given in my database and current date. The date in
my
database is in "dd/mm/yyyy" format. For example:
Dim DBDate '(date in database)
DBDate = fp_fieldVal(fp,rs ("Committed_Date") 'Date from recordset
Dim CurrentDate
CurrentDate = Date()
No_of_Days = DBDate - CurrentDate
The above code gives me following error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "17/08/2002"]'
/mysite/final-1.asp, line 187
Perhaps it tells me to convert the database date into a string however, I
tried with CStr() function but it didn't work. When I use a fixed date
with
above code i.e.
Days = (#17/08/2002# - Date()) then it works but there are different dates
in my database.
I also used the:
No_of_days = DateDiff("d", CurrentDate, DBDate)
It works 95% but surprisingly gives wrong value in some of the
calculations
!!!!!!!
Please help.
Thanks,
Rakesh
---------------------------------
Do you Yahoo!?
Yahoo! News - Today's headlines
---------------------------------
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
Message #7 by "Drew, Ron" <RDrew@B...> on Sun, 15 Sep 2002 11:14:41 -0400
|
|
The following shows all my members that joined between July and December
using an access database...
SELECT Members.Member, Members.FirstName, Members.SpouseName,
Members.Address1, RTrim([Members]![City])+",
"+RTrim([Members]![State])+" "+RTrim([Members]![Zip]) AS Expr3,
Members.JoinDate
FROM Members
WHERE ((([Members]![JoinDate]) Between #7/1/2002# And #12/1/2002#))
ORDER BY Members.Member;
-----Original Message-----
From: Vijay G [mailto:happygv@y...]
Sent: Friday, September 13, 2002 11:58 PM
To: ASP Databases
Subject: [asp_databases] Re: Number of days
Rakesh,
I just checked, in access too you can use the datediff() for finding
difference between 2 dates.
Also In VB there is a datediff() method to find diff between 2 dates.
in access - select datediff('d',dateField,date()) from table1
in VB - datediff('d',FieldValueFromDatabase,date())
Let us know the result.
Cheers!!!
Vijay G
Rakesh Parekh wrote:Hello Vijay,
I use Microsoft Access as my database. What you have replied is clear to
me but then what is the solution that I can calculate number of days
between current date and a date in Microsoft Access database with
Date/Time type.
Thanks,
Rakesh
>
If your database is in SQL, Use DateDiff function to return the
value....
Cheers!!!
Vijay G
Rakesh Parekh wrote:Hello,
I have a date field in my database. I want to calculate and show the
number
of days between a date given in my database and current date. The date
in
my
database is in "dd/mm/yyyy" format. For example:
Dim DBDate '(date in database)
DBDate =3D fp_fieldVal(fp,rs ("Committed_Date") 'Date from recordset
Dim CurrentDate
CurrentDate =3D Date()
No_of_Days =3D DBDate - CurrentDate
The above code gives me following error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "17/08/2002"]'
/mysite/final-1.asp, line 187
Perhaps it tells me to convert the database date into a string however,
I
tried with CStr() function but it didn't work. When I use a fixed date
with
above code i.e.
Days =3D (#17/08/2002# - Date()) then it works but there are different
dates
in my database.
I also used the:
No_of_days =3D DateDiff("d", CurrentDate, DBDate)
It works 95% but surprisingly gives wrong value in some of the
calculations
!!!!!!!
Please help.
Thanks,
Rakesh
---------------------------------
Do you Yahoo!?
Yahoo! News - Today's headlines
---------------------------------
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
|
|
 |