 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 12th, 2004, 07:54 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Date Problem
Hi All,
I am try to add the current date into my access database. I only want dd/mm/yyyy so i format my date like this.
Code:
' Format Date
showDate = DatePart("d", Now()) & "/" & DatePart("m", Now()) & "/" & DatePart("yyyy", Now())
It enters the date as 30/12/1899 which must be a default date.
The funny thing is that when i output showDate on the screen it displays correctly but not when adding to the DB.
I have also check that it is a valid date.
Any suggestions.
Thanks Tim
TDA
__________________
TDA
|
|

August 12th, 2004, 08:27 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hello TDA,
Check your system date whether it is correct or not. Or
showDate=day(date) & "/" & month(date) & "/" & year(date)
|
|

August 12th, 2004, 08:38 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
It is wise to enter dates into the database as yyyy/mm/dd.
This way the database will get it right. (at least MSSQL,ACCESS,MSDE)
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|

August 12th, 2004, 09:06 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
My system time is correct, ive tried all combinations and also tried asigning the database field as Date and Now() and the only difference when i go yyyy/mm/dd is that it gives me 18/1/1900
Any ideas what im doing wrong.
TDA
|
|

August 12th, 2004, 09:13 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
What DB are you using?
Can you post the entire SQL statement that is being sent to the DB?
Check your regional settings are set to Australia.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|

August 12th, 2004, 09:41 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes my regional settings are set to Australia. dd/mm/yyyy
Im using MS Access2000 and my datatype for DeedDate is Date/Time (Medium)
Here is my code
' Format Date
showDate=day(date) & "/" & month(date) & "/" & year(date)
' enable opportunity
strUpdate = "UPDATE Registrations SET DeedStatus = " & 1 & ", DeedDate = "& showDate &" WHERE RegistrationID = " & ID
objConn.Execute(strUpdate)
No matter how i change the format of the showDate or put in Date or Now() directly into the SQL it doesn't work.
thanks Tim
TDA
|
|

August 12th, 2004, 09:47 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Tim,
You will need to enclose the date in single quotes.
Code:
DeedDate = '"& showDate &"' WHERE
This will fix the problem but I still recommend using yyyy/mm/dd for the format when putting into the database.
CARN' THE DOCKERS
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|

August 12th, 2004, 09:50 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Actually MS ACCESS may require a hash, try both
DeedDate = #"& showDate &"# WHERE
But I think it should be ok through ODBC.
ANY ACCESS GURU's out there may confirm.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|

August 12th, 2004, 10:01 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Rod,
It worked! DAM THOSE SINGLE QUOTES
I have taken your advice about formatting dates yyyy/mm/dd
BTH: I tested both ways and you can use the # aswell, but from memory mssql chucks the sads if you use #
Thanks again mate
Tim :)
TDA
|
|

August 12th, 2004, 10:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
No worries, anytime.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| DATE PROBLEM |
ricespn |
Classic ASP Basics |
3 |
October 20th, 2006 07:15 AM |
| Date Problem |
kuku |
SQL Server 2000 |
4 |
September 7th, 2005 08:38 PM |
| Date Problem. |
rupen |
Classic ASP Basics |
3 |
June 3rd, 2005 09:58 AM |
| date problem |
hosefo81 |
PHP How-To |
2 |
May 26th, 2004 11:12 AM |
| Date problem |
Larson |
VB How-To |
2 |
December 30th, 2003 06:10 PM |
|
 |