Wrox Programmer Forums
|
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
 
Old October 19th, 2006, 03:16 PM
Authorized User
 
Join Date: Oct 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ricespn
Default DATE PROBLEM

Hi,

I'm trying to do a query into SQL 2000 and I found out that the record has date of "2006-10-19 15:04:51.687" and my query is getting the date from the same column but in my SQL query string appears like this "10/19/2006 3:04:52 PM".

How can I pass the same value from SQL to my variable and keep the date value intact instead of having PM at the end and the seconds rounded to the next?

Thanks.

Strange and crazy, but everything is possible
__________________
=======================
Strange and crazy, but everything is possible
 
Old October 19th, 2006, 03:27 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If you mean you are trying to just get the date as 10/19/2006 sent to your application you would do this:

SELECT convert(varchar(10), datefieldname, 101) from table

And this will return 10/19/2006 as your result set.

hth

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 19th, 2006, 04:05 PM
Authorized User
 
Join Date: Oct 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ricespn
Default

This is my select string:

SELECT * FROM mfworkpartref WHERE partno='123-456-789' AND refpartno= '123-456-789' AND refqty= '2000' AND factoryid='IPCBU' AND skuno='123-456-789' AND createdby='RICARDO' AND createddt='10/19/2006 3:04:52 PM'

this is my record values:

123-456-789
123-456-789
2000
IPCBU
123-456-789
RICARDO
2006-10-19 15:04:51.687

As you can see the date is beeing saved using SQL function GETDATE() that records the date and time. When I put that value into a variable it gets converted to "10/19/2006 3:04:52 PM" so in my query I don't get any records because of the datetime.

Strange and crazy, but everything is possible
 
Old October 20th, 2006, 07:15 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

That is how get date works, its the current date and time of the server at the time you call it. However you can still select columns based on just the date here is what you have to do:

SELECT
column,
column,
column,
convert(varchar(10), datefield, 101) as [Createddt]
from table
where [clause]

That select statement will return you just the datepart of the datetime field then you can set the column value to a variable and then your createddt part of your where clause will just be:
Dim sDate
sDate = rs("createddt")
SELECT * from table where createddt = & sDate

hth

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
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 tdaustin Classic ASP Basics 10 August 13th, 2004 01:43 PM
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





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