Date type in ASP/Javascript/SQL
am 06.12.2006 13:11:30 von Jan Paul van de Berg
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("SomeDateField")));
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").Value).getDa te());
error: 'rs.Fields.Item(...).Value' is null or not an object
4)
Response.write((rs.Fields.Item("SomeDateField")).getDate());
error: Object doesn't support this property or method
5)
Response.write(CDate(rs.Fields.Item("SomeDateField")).getDat e());
error: Object expected
Re: Date type in ASP/Javascript/SQL
am 07.12.2006 23:03:16 von Phillip Windell
This link answers many date related questions.
http://www.aspfaq.com/search.asp?q=format&type=ALL&category= 6&numDays=0&order=1
--
Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
The views expressed are my own (as annoying as they are), and not those of
my employer or anyone else associated with me.
-----------------------------------------------------
"Jan Paul van de Berg" wrote in message
news:gkluzyo712mr.ieegu9pg211q$.dlg@40tude.net...
> 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("SomeDateField")));
> 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").Value).getDa te());
> error: 'rs.Fields.Item(...).Value' is null or not an object
>
> 4)
> Response.write((rs.Fields.Item("SomeDateField")).getDate());
> error: Object doesn't support this property or method
>
> 5)
> Response.write(CDate(rs.Fields.Item("SomeDateField")).getDat e());
> error: Object expected