Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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
 
Old September 28th, 2003, 01:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default sysdate

How can insert system date in sql server by ASP page ?
It insert 1/1/1900 date,
During data entry, I want that system date automatically insert in sql server.


isql1="insert into stations2 (stn_no,curnt_user,purchase_date,cost,model,rec_up date,remarks) values ("
isql2="'" & stn_no & "',"
isql3="'" & curnt_user & "',"
isql4="'" & purchase_date & "',"
isql5= cost & ","
isql6="'" & model & "',"
isql7="'" & sysdate & "'," // how can insert sysdate
isql8="'" & remarks & "')"

isql=isql1+isql2+isql3+isql4+isql5+isql6+isql7+isq l8

cn.Execute isql


Mateen
 
Old September 28th, 2003, 03:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SQL Server has an internal function called GetDate which you can use instead of creating a date in ASP, then passing this across to SQL Server to intepret:

isql6="'" & model & "',"
isql7=" GetDate(), "
isql8="'" & remarks & "')"

Cheers
Ken

www.adOpenStatic.com
 
Old September 28th, 2003, 03:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks


Quote:
quote:Originally posted by KenSchaefer
 SQL Server has an internal function called GetDate which you can use instead of creating a date in ASP, then passing this across to SQL Server to intepret:

isql6="'" & model & "',"
isql7=" GetDate(), "
isql8="'" & remarks & "')"

Cheers
Ken

www.adOpenStatic.com
 
Old September 28th, 2003, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can also use the SQL-92 standard CURRENT_TIMESTAMP instead of the proprietary getdate().

You may also want to consider defining a DEFAULT constaint on the column which would set the value automatically whenever rows are inserted, rather than providing the value in the INSERT itself. Note also that doing this would guarantee that the date and time used is the data and time of the database server, and not your web server, which may or may not be the same...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to subtract hours from sysdate in oracle mcmouli Oracle 4 January 7th, 2011 06:52 AM
Urgent help! Compare a string to Sysdate in Oracle WroteForLuck Classic ASP Basics 1 July 22nd, 2003 01:48 AM
Urgent help needed! Compare a string to Sysdate in WroteForLuck Classic ASP Professional 1 July 17th, 2003 06:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.