473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Date type in ASP/Javascript/SQL

How do I handle date methods like getDate() on values I get from a
recordset? Example:

rs.Source= "Select SomeDateField From SomeTable"
....

1)
Response.write(rs.Fields.Item("SomeDateField"));
output: 11/16/2006

2)
Response.write(String(rs.Fields.Item("SomeDateFiel d")));
output: Thu Nov 16 00:00:00 EST 2006

Since there's a difference I would expect rs.Fields.Item("SomeDateField")
is a date type. But I cannot apply date methods:

3)
Response.write((rs.Fields.Item("SomeDateField").Va lue).getDate());
error: 'rs.Fields.Item(...).Value' is null or not an object

4)
Response.write((rs.Fields.Item("SomeDateField")).g etDate());
error: Object doesn't support this property or method

5)
Response.write(CDate(rs.Fields.Item("SomeDateField ")).getDate());
error: Object expected
Dec 6 '06 #1
1 1301

Jan Paul van de Berg wrote:
How do I handle date methods like getDate() on values I get from a
recordset? Example:

rs.Source= "Select SomeDateField From SomeTable"
...

1)
Response.write(rs.Fields.Item("SomeDateField"));
output: 11/16/2006

2)
Response.write(String(rs.Fields.Item("SomeDateFiel d")));
output: Thu Nov 16 00:00:00 EST 2006

Since there's a difference I would expect rs.Fields.Item("SomeDateField")
is a date type. But I cannot apply date methods:

3)
Response.write((rs.Fields.Item("SomeDateField").Va lue).getDate());
error: 'rs.Fields.Item(...).Value' is null or not an object

4)
Response.write((rs.Fields.Item("SomeDateField")).g etDate());
error: Object doesn't support this property or method

5)
Response.write(CDate(rs.Fields.Item("SomeDateField ")).getDate());
error: Object expected
Hi

Does ".VALUE" return a VT_DATE? In which case you may need to do

var jsDate = new Date(rs.Fields.Item("SomeDateField").Value);

Regards

Julian

Dec 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
2
by: m | last post by:
hi all, got an interesting problem: im working with purchase orders and in detail line i have a date field. so for example: header line: PO code: X123 PO value: ...
14
by: Steve Wright | last post by:
I am trying to validate if an entry on a form is a date. I have adapted code I found here http://www.codingforums.com/archive/index.php/t-14325 as below but I can't seem the get the results that I...
8
by: dlx_son | last post by:
Here is the code so far <form name="thisform"> <h3>Enter time to add to or subtract from:</h3> (If not entered, current time will be used)<br> Day: <input name="d1" alt="Day of month"...
38
by: | last post by:
I have a script... ----- <SCRIPT language="JavaScript" type="text/javascript"> <!-- function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this = makeArray.arguments; } ...
4
by: Kun | last post by:
i have a form which takes in inputs for a mysql query. one of the inputs is 'date'. normally, a user has to manually enter a date, but i am wondering if there is a way to create a button which...
9
by: mistral | last post by:
Need help to remove list of days from date script. Need format "June 07, 2006" <SCRIPT LANGUAGE="JavaScript"> <!-- Begin // Get today's current date. var now = new Date();
15
by: Cerebral Believer | last post by:
Hi all, I am a newbie to JavaScript and am just trying to get a script going that will write the ful date and time to each webpage as it is viewed. Can anyone point out what mistakes there are...
6
by: ruraldev | last post by:
I have been trying my best to display a chosen date as dd-mm-yyyy but insert it into the mysql database as yyyy-mm-dd, I know it must be simple but no matter what I try I can't get it to work. At...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.