469,362 Members | 2,285 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

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 1207

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Richard Hollenbeck | last post: by
14 posts views Thread by Steve Wright | last post: by
38 posts views Thread by | last post: by
4 posts views Thread by Kun | last post: by
15 posts views Thread by Cerebral Believer | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.