Although not strictly required, I (almost) always use the database engine's
data conversion function to specify dates (in a SQL statement), and I
explicitly tell it what format I am giving it.

For SQL Server, that function is CONVERT(), and I include the optional 3rd
parameter (STYLE), usually specifying Style 120 (yyyy-mm-dd hh24:nn:ss).

If you use an ADO result set, you should assign a Date subtype to the field
value.  Unfortunately, VB[Script] does not provide any way to explicitly
tell it what format you are converting *from*, so you either have to make
sure the date format is according to the (in asp) web server's regional
settings and/or you web pages specified locale, or you can keep the datetime
portions separate, and use DateSerial(<year>, <month>, <day>) +
TimeSerial(<hours>, <minutes>, <seconds>) to ensure proper conversion to a
datetime data type.

HTH,
Tore.


-----Original Message-----
From: Dylan Barber [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 23, 2002 8:46 AM
To: ActiveServerPages
Subject: SQL and dates in a page


I have a news script that inserts a news item into a database (MS SQL
server 2000)  the table has a release date field that I want to check
against the current date.  Sounds simple right.  However I can not
figure out how to submit a datetime to the Database so Right now I can't
check the date can anybody help me?

__________________________________________________
Dylan Barber (CIW Professional, A+ Technician)
Programmer/Analyst
DPRA Inc.
phone (785) 539-3565 ext.1034
e-mail [EMAIL PROTECTED]


---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to